【发布时间】:2014-05-31 13:49:41
【问题描述】:
我有这种 XML
...
<config>
<parameters>
<location attribute1="toto" attribute2="anotherThing"/>
<other attribute1="toto" attribute2="anotherThing"/>
<other2 attribute1="toto" attribute2="anotherThing"/>
</parameters>
</config
...
(请注意,这是一个非常愚蠢的例子,我理解这对于具体数据可能没有意义)。
我的 XmlReader 目前在 parameters 节点上,我想读取所有子元素(直到我看到 </parameters>)
如何使用 XmlReader 检索它? (因为我在更大的框架中,所以必须使用 XmlReader)。
谢谢。
【问题讨论】:
-
XmlReader.ReadSubTree 将是我的第一个停靠港。
-
@Dmitry 是的,我可以这样做,但在我的真实情况下,我有 20 多个可能的孩子类型,所以我更喜欢阅读它们,然后查看它们对应的内容而不是尝试阅读很多东西不在这里。
-
@TonyHopkinson:我去看看这个方法,谢谢!
标签: c# .net xml parsing xmlreader