Forum Moderators: open
<purse>
<coin>
<value>0.5</value>
<name lang="en">half dollar</name>
</coin>
<coin>
<value>0.25</value>
<name lang="en">quarter</name>
</coin>
</purse>
What is the XPath expression that would give the name of the first attribute element of the first name element?
guessing this, but I am really not sure...
name(/purse/coin[1]/name/@[1])
or maybe
name(/purse/name[1]/@[1])
?
thanks
The solution would be to move the data from an attribute to an element, whose ordering parsers must obey.
For a few rants on the subject trying searching for "xml attribute ordering".
Looking at your example, it would seem natural for the "lang" element to be an attribute. Why can you not select for /purse/coin[1]/name[@lang="en"]?
would probably work, however, this is for an assignment for a Java class. Our textbook is terribly brief and I cannot find a clear answer in it.
I think I need to use some other path statement that doesn't directly refer to the attribute by specifying the name.
thanks