I'm afraid that we will need to make sure your XPath statement is certain, but I think this is a problem with namespaces.
Elements that do not have a prefix are located in the default namespace , which sets it to http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition for the above document.
In XPath queries, you now need to include these namespaces in your queries. This way selectSingleNode ( /elementnameicanseeinnotepad ) will not give you anything.
To add namespaces to the query, you will need to use the XmlNamespaceManager class (or use the detailed XPath syntax, which I do not 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.
source share