You are trying to select Document elements that do not have a namespace ... whereas the default namespace is actually "urn: Microsoft.Search.Response" here.
I think you need something like this:
XmlDocument xmlResults = new XmlDocument(); xmlResults.LoadXml(xml); XmlNamespaceManager manager = new XmlNamespaceManager(xmlResults.NameTable); manager.AddNamespace("ns", "urn:Microsoft.Search.Response.Document"); XmlNodeList results = xmlResults.SelectNodes("//ns:Document", manager);
This finds two elements.
If you can use LINQ to XML, this will simplify:
XDocument results = XDocument.Parse(xml); XNamespace ns = "urn:Microsoft.Search.Response.Document"; var documents = results.Descendants(ns + "Document");
I like LINQ to XML namespace handling :)
Jon skeet
source share