【发布时间】:2011-10-11 21:34:17
【问题描述】:
我在LINQ to XML 上进行了大量阅读,但不幸的是,这个主题(对我来说相当新)根本不会点击。话虽如此,请随时纠正有关正确 XML 词汇的任何错误说法。我的目标是获取 XML 数据(如下所示),并逐个节点地读取它。在这种情况下,我希望能够打开 Delimiters 节点,以获取“one”、“two”的值”和“三个”元素。接下来,我想从 中获取“one”、“two”和“three”元素的值>Sources/SourceType 节点。
<?xml version="1.0"?>
<Values>
<Delimiters>
<one>delim 1</one>
<two>delim 2</two>
<three>delim 3</three>
</Delimiters>
<Sources>
<SourceType>
<one>type 1</one>
<two>type 2</two>
<three>type 3</three>
</SourceType>
</Sources>
</Values>
我已经阅读了XMLTextReader 和XMLReader,但我想听听你们所有人对我的情况的最佳做法。
感谢您的阅读,
埃文
【问题讨论】:
标签: c# xml linq-to-xml readxml