XML查询问题
我正在尝试从 C# 编码的 xml 文件中获取一些数据。
如果以下claim-ib-info节点不包含已撤回,如何获取claim节点的数据节点。
如果您不清楚我的问题,请告诉我。
我对 XML 不太了解,提前致谢。
<info>
<claim kind="national" sequence="1">
<country>UK</country>
<number>66</number>
<date>20080602</date>
</claim>
<claim-ib-info>
<received-at>
<date>20090610</date>
</received-at>
</claim-ib-info>
<claim kind="national" sequence="2">
<country>US</country>
<number>125</number>
<date>20080501</date>
</claim>
<claim-ib-info>
<withdrawn>
<date>20100721</date>
</withdrawn>
</claim-ib-info>
<claim kind="national" sequence="3">
<country>TH</country>
<number>61</number>
<date>20090316</date>
</claim>
<claim-ib-info>
<received-at>
<date>20090610</date>
</received-at>
</claim-ib-info>
<claim kind="national" sequence="4">
<country>MY</country>
<number>66</number>
<date>20090209</date>
</claim>
<claim-ib-info>
<withdrawn>
<date>20101221</date>
</withdrawn>
</claim-ib-info>
</info>
I am trying to get some data from xml file from my C# coding.
How can I get the data of claim node if the following claim-ib-info node does not contain withdrawn node.
If you are not clear about my question, let me know.
I don't know much about XML and thanks in advance.
<info>
<claim kind="national" sequence="1">
<country>UK</country>
<number>66</number>
<date>20080602</date>
</claim>
<claim-ib-info>
<received-at>
<date>20090610</date>
</received-at>
</claim-ib-info>
<claim kind="national" sequence="2">
<country>US</country>
<number>125</number>
<date>20080501</date>
</claim>
<claim-ib-info>
<withdrawn>
<date>20100721</date>
</withdrawn>
</claim-ib-info>
<claim kind="national" sequence="3">
<country>TH</country>
<number>61</number>
<date>20090316</date>
</claim>
<claim-ib-info>
<received-at>
<date>20090610</date>
</received-at>
</claim-ib-info>
<claim kind="national" sequence="4">
<country>MY</country>
<number>66</number>
<date>20090209</date>
</claim>
<claim-ib-info>
<withdrawn>
<date>20101221</date>
</withdrawn>
</claim-ib-info>
</info>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试学习和使用Linq to XML。
Try to learn and use Linq to XML.
我建议首先学习 XPath。 XPath(与 LINQ 不同)是一种开放技术;您可以在任何平台上使用任何支持 XML 的语言和库:
http: //msdn.microsoft.com/en-us/library/d271ytdx.aspx
I'd recommend learning XPath first. XPath (unlike LINQ) is an open technology; you can use it on any platform, with any XML-aware language and library:
http://msdn.microsoft.com/en-us/library/d271ytdx.aspx