I need to retrieve the attribute itself, NOT the attribute value, from a specific node.
我需要从特定节点检索属性本身,而不是属性值。
For example for Object 2, the attribute is "operation" not "update"and for Object3, the attribute is "name" not "A51". If I want to get the attribute value, I would use something like node2.getAttribute("operation")
but that's not what I want
例如,对于对象2,属性是“操作”而不是“更新”,对于对象3,属性是“名称”而不是“A51”。如果我想获取属性值,我会使用像node2.getAttribute(“operation”)这样的东西,但这不是我想要的
<Object1 class="second"/>
<Object2 operation="update"/>
<Object3 name="A51"/>
1 个解决方案
#1
0
I found the way. It's really simple, just add .Attributes.Item(i).nodeName
to your node. i
is just the attribute position. In my case it would be:
我找到了方法。它非常简单,只需将.Attributes.Item(i).nodeName添加到您的节点即可。我只是属性位置。在我的情况下,它将是:
node1.Attributes.Item(0).nodeName
#1
0
I found the way. It's really simple, just add .Attributes.Item(i).nodeName
to your node. i
is just the attribute position. In my case it would be:
我找到了方法。它非常简单,只需将.Attributes.Item(i).nodeName添加到您的节点即可。我只是属性位置。在我的情况下,它将是:
node1.Attributes.Item(0).nodeName