XPathDocument doc = new XPathDocument("books.xml"); XPathNavigator nav = doc.CreateNavigator(); nav.MoveToChild("book", ""); string ns = nav.GetNamespace("xmlns"); Console.WriteLine("Namespace URI: {0}", ns);
XPathDocument doc = new XPathDocument("books.xml"); XPathNavigator nav = doc.CreateNavigator(); nav.MoveToRoot(); string ns = "http://www.example.com/books"; XPathNodeIterator iter = nav.SelectChildren("*", ns); while (iter.MoveNext()) { Console.WriteLine(iter.Current.Name); }The above examples use the System.Xml.XPath package library.