XDocumentとDescendantsメソッドを使用しています。XDocument.Descendantsがエンティティを期待通りにフェッチしないC#.NET XML処理
//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;
同じXDocumentコードは、私のブログすなわち、より冗長のブログのフィード上で動作します:http://blog.nick.josevski.com/feed/スニペットはここにある:「エントリ」要素が「項目」と「ID」に置き換えられhttp://pastebin.com/KU65dgwLが置き換えられ'リンク'。
提案をテストするために、問題を示すLinqPad code gistを作成しました。
明らかなものがありませんか?私は.Elements()
.Elements("entry")
とちょうど.Descendants()
のさまざまな組み合わせを試してみました。
これは私からのエントリー/ IDノードを抽出するために苦労していたXMLです:あなたはXML名前空間を欠けている
<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>
おかげで - に要旨を更新修正を含める。 https://gist.github.com/1614853 –