Using an XDocument and the Descendants method.
//first problem 'entries' doesn't fetch at all
var entries = xmlDoc.Descendants(XName.Get("entry"))
//neither does
// xmlDoc.Descendants("entry")
var ids = from e in entries
select e.Element(XName.Get("id")).Value;
The same XDocument code works on a blog feed that’s more verbose, i.e. my blog: http://blog.nick.josevski.com/feed/ a snippet is here: http://pastebin.com/KU65dgwL where the ‘entry’ element is replaced with ‘item’ and ‘id’ is replaced with ‘link’.
To test any suggestions I created a LinqPad code gist that demonstrates the issue.
Am I missing something obvious? I’ve tried various combinations of .Elements() .Elements("entry") and just .Descendants() and then attempting to filter further without luck too.
This is the XML that I’m struggling to extract the entry/id node from:
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">Author</title>
<subtitle type="text">subtitle</subtitle>
<link rel="alternate" href="http://www.site.com/blog" />
<entry>
<id>http://www.site.com/a-blog-post</id>
<title type="text">Title Of Blog Post</title>
...
<entry>
<id>http://www.site.com/another-blog-post</id>
<title type="text">Title Of Another Blog Post</title>
You are missing the XML namespace: