我有这个XML:
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:re="http://purl.org/atompub/rank/1.0">
<title type="text">Recent Questions - Stack Overflow</title>
<link rel="self" href="http://stackoverflow.com/feeds" type="application/atom+xml" />
<link rel="alternate" href="http://stackoverflow.com/questions" type="text/html" />
<subtitle>most recent 30 from stackoverflow.com</subtitle>
<updated>2011-04-28T13:53:52Z</updated>
<id>http://stackoverflow.com/feeds</id>
<creativeCommons:license>http://www.creativecommons.org/licenses/by-nc/2.5/rdf</creativeCommons:license>
<entry>
<id>http://stackoverflow.com/questions/5819742/how-do-i-run-a-slow-running-batch-asynchronously-specifically-a-svn-post-commit</id>
<re:rank scheme="http://stackoverflow.com">0</re:rank>
<title type="text">How do I run a slow running batch Asynchronously, specifically a SVN post-commit?</title>
<category scheme="http://stackoverflow.com/feeds/tags" term="windows"/><category scheme="http://stackoverflow.com/feeds/tags" term="svn"/><category scheme="http://stackoverflow.com/feeds/tags" term="batch"/><category scheme="http://stackoverflow.com/feeds/tags" term="post-commit"/>
<author>
<name>digiguru</name>
<uri>http://stackoverflow.com/users/5055</uri>
</author>
<link rel="alternate" href="http://stackoverflow.com/questions/5819742/how-do-i-run-a-slow-running-batch-asynchronously-specifically-a-svn-post-commit" />
<published>2011-04-28T13:53:48Z</published>
<updated>2011-04-28T13:53:48Z</updated>
<summary type="html">
whatever1
</summary>
</entry>
<entry>
<id>http://stackoverflow.com/questions/5818592/wxpython-making-a-panel-not-accessible-through-tab</id>
<re:rank scheme="http://stackoverflow.com">0</re:rank>
<title type="text">wxPython making a panel not accessible through tab</title>
<category scheme="http://stackoverflow.com/feeds/tags" term="wxpython"/><category scheme="http://stackoverflow.com/feeds/tags" term="wxglade"/>
<author>
<name>ccwhite1</name>
<uri>http://stackoverflow.com/users/588892</uri>
</author>
<link rel="alternate" href="http://stackoverflow.com/questions/5818592/wxpython-making-a-panel-not-accessible-through-tab" />
<published>2011-04-28T12:30:02Z</published>
<updated>2011-04-28T13:53:34Z</updated>
<summary type="html">
whatever 2
</summary>
</entry>
</feed>
是来自StackOverflow的最新供稿的RSS的一部分。
我需要恢复整个xml(我正在使用Linq到XML。),但只使用了一个“更新”的属性,其值小于或等于参数传递的DateTime。 / b>
我这样得到了xml:
XDocument recientes = XDocument.Load(ObtenerFeedsRecientes());
recientes = recientes.Root.Elements().DontKnowWhatToDo();
有人可以告诉我如何做到这一点吗?
谢谢!
答案 0 :(得分:3)
XDocument recientes = XDocument.Load(ObtenerFeedsRecientes());
XNamespace atomNS = "http://www.w3.org/2005/Atom";
var updates = from entry in recientes.Root.Elements(atomNS + "entry")
where DateTime.Parse(entry.Element(atomNS + "updated").Value) <= parameter
select entry;
应该做的伎俩。这假定parameter
属于DateTime