Skip to content

Instantly share code, notes, and snippets.

@NickJosevski
Created January 14, 2012 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickJosevski/1611160 to your computer and use it in GitHub Desktop.
Save NickJosevski/1611160 to your computer and use it in GitHub Desktop.
linq to xml handing of namespaces on node selection
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