get node depending of parent position (but nodename of parent is unknown)
Posted: Wed Aug 08, 2018 12:36 pm
Hi all,
we have different XML files where we want to extract the value of a node with name <S_NAD> depending on the current position
We know that <S_NAD>-node is a grandchild of the root. Example
The difficulty is, that the nodename of the child of the root varies. In the example it is: <unknownName>
I wrote a XPATH, but this works wrong:
But this gives me:
1) XPath Location: /book[1]/unknownName[1]
2) XPath Location: /book[1]/unknownName[2]
where I only expected the first line.
Could anybody please help?
Thanks
Regards Mario
we have different XML files where we want to extract the value of a node with name <S_NAD> depending on the current position
We know that <S_NAD>-node is a grandchild of the root. Example
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<book>
<unknownName>
<S_NAD>some content</S_NAD>
</unknownName>
<unknownName>
<S_NAD>some content</S_NAD>
</unknownName>
</book>
The difficulty is, that the nodename of the child of the root varies. In the example it is: <unknownName>
I wrote a XPATH, but this works wrong:
Code: Select all
/*/*/S_NAD/parent::*[position()=1]
1) XPath Location: /book[1]/unknownName[1]
2) XPath Location: /book[1]/unknownName[2]
where I only expected the first line.
Could anybody please help?
Thanks
Regards Mario