如何在XML中包含相同的命名节点时选择特定节点 [英] How to select a particular node in XML when it contains same named nodes

查看:136
本文介绍了如何在XML中包含相同的命名节点时选择特定节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XL文件有几个同名的节点。



我想逐个选择这些节点用于进一步的目的。



I am having an XL file having several nodes of same name.

I want to select these nodes one by one for further purpose.

<Shapes>

<Square>
<Vertex x="221" y="12" z="432">
</Square>

<Square>
<Vertex x="123" y="42" z="645">
</Square>

<Square>
<Vertex x="987" y="512" z="667">
</Square>

</Shapes>







这里我要t o在名为Square的所有节点中选择属性值。



我想逐个选择节点。



如何执行此操作




Here I want to select attribute values in all nodes named Square.

I want to select nodes one by one.

How to do this

推荐答案

我会使用XDocument,或者您也可以使用XmlDocument。 XDocument更新,支持Linq。



http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument_methods(v = vs.110)的.aspx [ ^ ]



您可以使用Elements()或Descendants()等。
I would use the XDocument or you could also use the XmlDocument. The XDocument is newer and supports Linq.

http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument_methods(v=vs.110).aspx[^]

You can use Elements() or Descendants() etc.


这篇关于如何在XML中包含相同的命名节点时选择特定节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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