EDN Admin
Well-known member
In the following code the XPath query does not find a match. By removing the xmlns attribute on the root element the XPath query works. Can anyone explain why this happens?
<pre class="prettyprint string xml = "<Books xmlns="http://www.tbd.org/xml <Book>foo</Book></Books>";
XmlDocument document = new XmlDocument();
document.LoadXml(xml);
XmlNode xmlNode = document.SelectSingleNode("//Book");[/code]
<br/>
View the full article
<pre class="prettyprint string xml = "<Books xmlns="http://www.tbd.org/xml <Book>foo</Book></Books>";
XmlDocument document = new XmlDocument();
document.LoadXml(xml);
XmlNode xmlNode = document.SelectSingleNode("//Book");[/code]
<br/>
View the full article