Using xpath and rdlc report

拟墨画扇 提交于 2019-12-05 16:19:38
Marvin Smit

I´m afraid we´ll need to see your XPath statement to be sure, but my guess is an issue with namespaces.

The elements that are not prefixed are in the default namespace which for the above document sets it to
http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition.

You XPath queries now need to include these namespaces in the queries. So, an selectSingleNode(/elementnameicanseeinnotepad) will not give you anything.

To add the namespaces in the query you will have to use the XmlNamespaceManager class (or use the verbose syntax of XPath which i don´t recommend).

// get an instance  
XmlNamespaceManager xMngr = new XmlNamespaceManager();
// associate the prefix ´def´ with the namespace-uri from the xml document we loaded
xMngr.AddNamespace( `def´, http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition);
// associate the prefix ´rd´ (same as used in document) with the namespace-uri from the xml document we loaded
xMngr.AddNamespace( `rd´, http://schemas.microsoft.com/SQLServer/reporting/reportdesigner);

// use the prefix(s) in the XPath query  
xDoc.DocumentElement.SelectSingleNode(´/def:elementnameiseeinnotepad´, xMngr );

Hope this helps.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!