日期:2014-05-18  浏览次数:20756 次

XML的读取问题
XML code

- <item>
  <title>新闻标题</title> 
  <link>http://www.mydomain.com/?q=node/11941</link> 
  <description><p>&lt;!--break--></p></description> 
  <comments>http://www.mydomain.com/?q=node/11941#comments</comments> 
  <category domain="http://www.mydomain.com/?q=taxonomy/term/1000">类别1</category> 
  <pubDate>Tue, 29 Jan 2008 02:32:13 +0000</pubDate> 
  <dc:creator>admin_name</dc:creator> 
  <guid isPermaLink="false">11941 at http://www.mydomain.com</guid> 
  </item>



以上XML我是这样绑定到GRIDVIEW的

<asp:XmlDataSource ID="XmlDataSource1" runat="server"></asp:XmlDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1" AutoGenerateColumns="false">

C# code

XmlDataSource1.DataFile = localpath;
XmlDataSource1.XPath = "/rss/channel/item";



pubDate表示新闻发布时间,现在我只想取出今天的新闻,该如何修改呢?

------解决方案--------------------
XmlDataSource1.XPath = "/rss/channel/item";这可以加判断条件的
------解决方案--------------------
XmlDataSource1.XPath = string.Format("/rss/channel/item[pubDate = '{0}']",今天的时间);