如何使用C#.NET读取XML中的XML节点 [英] How to read XML Nodes in XML using c#.net

查看:105
本文介绍了如何使用C#.NET读取XML中的XML节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有象下面这样的XML文件:

I have a XML file like below:

<report timestamp="3201" reportVersion="2" request="3981135340">
<question timedOut="false" time="3163" attempts="2" correct="true" id="13"> 
<answer status="attempt"> 
<radioButton correct="false" value="true" id="17" /> 
</answer> 
<answer status="correct"> 
<radioButton correct="true" value="true" id="15" /> 
</answer> 
</question> 
</report>

我想根据'答案'节点的状态属性来读取子节点。

I want to read the child nodes based on 'status' attribute of 'answer' node.

推荐答案

使用的的XmlReader (最快,但只进)的 的XDocument(LINQ到XML)或的XmlDocument 。请参阅MSDN文档中的例子。

Use XmlReader (fastest but forward only), XDocument (LINQ to XML) or XmlDocument. See the examples in the msdn documentation.

这篇关于如何使用C#.NET读取XML中的XML节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆