Created
January 14, 2012 11:55
-
-
Save NickJosevski/1611160 to your computer and use it in GitHub Desktop.
linq to xml handing of namespaces on node selection
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
void Main() | |
{ | |
//demonstrating linq to xml handing of namespaces, using the feedburner style on Scott Hanselman's blog. | |
var request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(@"http://feeds.feedburner.com/ScottHanselman"); | |
using (var response = request.GetResponse()) | |
{ | |
var xmlDoc = XDocument.Load(response.GetResponseStream()); | |
var ns = XNamespace.Get(@"http://rssnamespace.org/feedburner/ext/1.0"); | |
var elems = from x in xmlDoc.Descendants(XName.Get("item")) | |
select x.Element(XName.Get("origLink", ns.NamespaceName)).Value; | |
elems.ToList().ForEach(Console.WriteLine); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment