的索引值I有如下的非可变XML文件:C#/ XML:读取属性给定元素
<products>
<product>
<attributes>
<att name="Name" value="TOTO" />
<att name="Surname" value="Toto" />
<att name="Age" value="10" />
</attributes>
</product>
<product>
<attributes>
<att name="Name" value="TATA" />
<att name="Surname" value="Tata" />
<att name="Age" value="20" />
</attributes>
</product>
<product>
<attributes>
<att name="Name" value="TITI" />
<att name="Surname" value="Titi" />
<att name="Age" value="30" />
</attributes>
</product>
</products>
使用C#,我需要提取值字段的节点的值其值等于名称和年龄,一个给定的索引处。很好的例子:输入查询将返回含有TITI的字符串,并含有30 另一个串。
就目前而言,我使用一个XmlDocument加载XML文件,并用的getElementsByTagName方法的XmlNodeList中获得所有属性;那么我可以显示这些元素,但是我不能只显示其中的两个,这取决于属性名称和索引。
充其量,我需要一个像myXmlNodeList.Node [“att”]。Attributes [“Name”]。AtIndex(x)。
谁能帮助我?
当然,你可能已经研究这个。 –
我已经搜索过,但还没有找到任何真正接近我的答案。我发现了有关获取属性感谢节点,节点归功于属性等等。此外,许多方法使用XDocument或XmlDocument,我不认为混合这些类会是最佳的。另外,我无法使用外部库来执行此任务。 –
的[如何阅读和分析在C#中的XML文件?(http://stackoverflow.com/questions/642293/how-do-i-read-and-parse-an-xml-file-in可能的复制-c) – Nasreddine