Skip to content

Instantly share code, notes, and snippets.

@leomao10
Created October 31, 2010 00:28
Show Gist options
  • Save leomao10/655926 to your computer and use it in GitHub Desktop.
Save leomao10/655926 to your computer and use it in GitHub Desktop.
How to use XPath to search an element with namespace
XDocument d = XDocument.Parse("<p:root xmlns:p='P'><p:e/></p:root>");
XmlNamespaceManager r = new XmlNamespaceManager(new NameTable());
r.AddNamespace("p", "P");
XElement e = d.XPathSelectElement("//p:e", r);
Console.WriteLine(e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment