Notifications
Clear all

[Closed] XML writing

myNodes = xmlDoc.selectNodes "//Group/Nd[@Name='Name_5']"

This will get you an array of nodes conforming to the xpath.

1 Reply
 MZ1
(@mz1)
Joined: 1 year ago

Posts: 0

We just know GroupNd is a XmlElement,We don’t know WHERE GroupNd is, we don’t know its position or index.So we wouldn’t be able to find the Node from array.

After looking at this page:

http://www.w3schools.com/xpath/xpath_axes.asp

I find a syntax similar to what I want

attribute::lang	>>>> Selects the lang attribute of the current node

Except we want something like this:
attribute::Name==“Name_5” >>>> Selects the name attribute of the current node with value “Name_5”

I’m not sure what the question is here. The second example you posted, creates two sets of identical nodes. You wanted a node from the second group and I gave you a way to get to it, through an array.
My latest suggestion will get you all Nd nodes with the “Name_5” attribute if they have a parent called “Group”, wherever they are in the xmldoc.
Now you’re saying that it’s unknown where the node is. If there are multiple nodes with the same hierarchy, how do you propose to tell them apart? You can only tell a node apart from the other if there’s some unique feature.
If there’s a specific case you’re concerned about you could share the actual xml, not just the demo xml. Otherwise we’re shooting in the dark.

Page 2 / 2