Don't use the XmlDocument
class if you are going to work with XPath queries. .NET has its own class for this purpose called XPathDocument
, which does not run any validation checking. When using XPath, avoid using //
to reduce the search, because //
searches the complete document.
XPathDocument Doc = new XPathDocument(FileName);
XPathNavigator nav = Doc.CreateNavigator();
XPathNodeIterator Iterator = nav.Select("/bookstore/book");