How to select a node's first child name? XPath
102,735
Solution 1
I don't know the exact context of your XML, but I believe this is the XPath you are looking for...
/Employee/Department/*[1]
The key part of this XPath is *[1]
, which will select the node value of the first child of Department
.
If you need the name of the node, then you will want to use this...
name(/Employee/Department/*[1])
Solution 2
You need something like:
local-name(/Employee/Department/*[1])
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on August 15, 2020Comments
-
Admin almost 4 years
I have an XML from which I have to select the name of the child of one of the nodes. I'm kind of a beginner in this, so I didn't find the Xpath expression to do it. I know the level of the node
Example
Name from
/Employee/Department/
but Department has children nodes of unknown names. I have to select the first child of Department node. How can I do this?