XmlDocument loadxml xmlns

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
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
 
Back
Top