2

Below is an example XML. I would like to retrieve the 'root node tag'.

  1. I would like to retrieve the text "Personnel" from the XML below. How do I achieve that using XPATH?
  2. How to retrieve the text "Age" when the age=34 using XPATH. No matter what I try I am getting only the value (i.e. '34') and not the tag (i.e. 'Age'). Please note that I would like to retrieve only the tag(i.e. 'Age') and not the 'value'('34').

Please help me this.

<Personnel>
  <Employee type="permanent">
        <Name>Seagull</Name>
        <Id>3674</Id>
        <Age>34</Age>
   </Employee>
  <Employee type="contract">
        <Name>Robin</Name>
        <Id>3675</Id>
        <Age>25</Age>
    </Employee>
  <Employee type="permanent">
        <Name>Crow</Name>
        <Id>3676</Id>
        <Age>28</Age>
    </Employee>
</Personnel>
user2608424
  • 183
  • 2
  • 10

1 Answers1

1

Use the name function:

name(/*)
choroba
  • 231,213
  • 25
  • 204
  • 289