XPathSelectElement选择第二时,有一个以上的 [英] XPathSelectElement select the second when there is more than one
本文介绍了XPathSelectElement选择第二时,有一个以上的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好不知道这是可以做到,但我知道这里有人会知道:)
Hi Not sure if this can be done but I know someone here will know :)
使用
XElement oNodeEquip = xmlDoc.XPathSelectElement("//ItemAry/Item/Equip");
怎么会在下面的第二个我选择装备:
how would I select Equip from the second in the following:
<TestInfo>
<ItemAry>
<Item>
<testData>ABC</testData>
</Item>
<Item>
<testData>XYZ</testData>
<Equip>xxx</Equip>
</Item>
</ItemAry>
</TestInfo>
总是会有在租赁2 &LT;项目&GT;
,我想从值将始终是在第二个节点&LT;项目&GT ;
there will always be at lease 2 <Item>
and the node I want the value from will always be in the second <Item>
这是使用.NET 4.0中一个WPF应用程序
this is a WPF app using .Net 4.0
推荐答案
试试这个XPath EX pression:
Try this XPath expression:
//ItemAry/Item[2]/Equip
这仅考虑第二个&LT;项目&GT;
元素
这篇关于XPathSelectElement选择第二时,有一个以上的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文