Created
June 28, 2011 13:43
-
-
Save jonpryor/1051157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
csharp> var x = "<response xmlns='http://example.org/'><video>Hi!</video></response>"; | |
csharp> var xs = new StringReader(x); | |
csharp> var d = new XmlDocument(); | |
csharp> d.Load(xs); | |
csharp> foreach (XmlNode n in d.DocumentElement.SelectNodes("video")) Console.WriteLine(n.Name); | |
# Note: no output | |
csharp> var mgr = new XmlNamespaceManager (d.NameTable); | |
csharp> mgr.AddNamespace("lol", "http://example.org/"); | |
csharp> foreach (XmlNode n in d.DocumentElement.SelectNodes("lol:video", mgr)) Console.WriteLine(n.Name); | |
video | |
# Note: you need to pass the XmlNamespaceManager to SelectNodes(). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment