我现在有一个xml文档,其中一个结点的属性是时间字符串,我想查找出所有大于某个时间的结点,怎样写?
我试过用doc.SelectNodes("root/AffairDate[@date>'2006-11-21']"),不过返回Null。下面是xml的内容:
<root currentID="0">
<AffairDate date="2006-11-21">
<Affair id="1">
<name>周一上午开会</name>
<content>周一上午9:00在第一会议室开例会,所有人必须参加</content>
<remindtime>2006-11-27 8:45:00</remindtime>
<createtime>2006-11-22 10:52:12</createtime>
<lastmodifytime>2006-11-22 10:52:12</lastmodifytime>
<createman>zyxun</createman>
</Affair>
<Affair id="2">
<name>周一下午开会</name>
<content>周一下午15:30在第一会议室开例会,所有人必须参加</content>
<remindtime>2006-11-27 15:00:00</remindtime>
<createtime>2006-11-22 10:52:12</createtime>
<lastmodifytime>2006-11-22 10:52:12</lastmodifytime>
<createman>zyxun</createman>
</Affair>
</AffairDate>
<AffairDate date="2006-11-22">
<Affair id="3">
<name>周一上午开会</name>
<content>周一上午9:00在第一会议室开例会,所有人必须参加</content>
<remindtime>2006-11-27 8:45:00</remindtime>
<createtime>2006-11-22 10:52:12</createtime>
<lastmodifytime>2006-11-22 10:52:12</lastmodifytime>
<createman>zyxun</createman>
</Affair>
</AffairDate>
</root>
我试过用doc.SelectNodes("root/AffairDate[@date>'2006-11-21']"),不过返回Null。下面是xml的内容:
<root currentID="0">
<AffairDate date="2006-11-21">
<Affair id="1">
<name>周一上午开会</name>
<content>周一上午9:00在第一会议室开例会,所有人必须参加</content>
<remindtime>2006-11-27 8:45:00</remindtime>
<createtime>2006-11-22 10:52:12</createtime>
<lastmodifytime>2006-11-22 10:52:12</lastmodifytime>
<createman>zyxun</createman>
</Affair>
<Affair id="2">
<name>周一下午开会</name>
<content>周一下午15:30在第一会议室开例会,所有人必须参加</content>
<remindtime>2006-11-27 15:00:00</remindtime>
<createtime>2006-11-22 10:52:12</createtime>
<lastmodifytime>2006-11-22 10:52:12</lastmodifytime>
<createman>zyxun</createman>
</Affair>
</AffairDate>
<AffairDate date="2006-11-22">
<Affair id="3">
<name>周一上午开会</name>
<content>周一上午9:00在第一会议室开例会,所有人必须参加</content>
<remindtime>2006-11-27 8:45:00</remindtime>
<createtime>2006-11-22 10:52:12</createtime>
<lastmodifytime>2006-11-22 10:52:12</lastmodifytime>
<createman>zyxun</createman>
</Affair>
</AffairDate>
</root>
解决方案 »
- 关于Timer 启动问题 求救!!
- 百分求一个问题
- 数据库集成进exe的问题
- 怎么把vc++里面的cstring转换为C#中的string 或int float 急急急 一定给分
- PInvoke中关于CallBack函数的一个问题
- winform中怎么实现以下功能 : 类似listbox中一行有字,有两个checkbox
- [代码分享]用C#操作Windows注册表(WinForm)
- 使用System.Management写了一个远程关机(重启)的程序,发现对NT4无效,NT4下没有WMI吗?
- 求教:看不明白结果
- 明华RF-35读卡器如何读CPU卡的UID号
- listview的排序问题!
- INFRAGISTICS 的 ULTRAWEBGRID 如何不刷新删除行
你说的不行,出现下面的错误
'root/AffairDate[@date:'2006-11-21']' has an invalid qualified name.
doc.SelectNodes("root/AffairDate"),得到所有的这类节点,再通过节点的date属性值过滤出你想要的结果。
http://www.microsoft.com/china/MSDN/library/data/xml/XPathintr.mspx