This is easier if you use LINQ to XML classes. Otherwise, namespaces are really annoying.
XNamespace ns = "http://schemas.datacontract.org/2004/07/FOO.WCF"; var doc = XDocument.Load("C:\\test.xml"); Console.Write(doc.Descendants(ns + "name").First().Value);
Change Usage 2.0
XmlDocument doc = new XmlDocument(); doc.Load("C:\\test.xml"); XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("a", "http://schemas.datacontract.org/2004/07/FOO.WCF"); Console.Write(doc.SelectSingleNode("//a:name", ns).InnerText);
source share