i want to get every <path> where <id_wert> = 1 from a xml file

Viewed 17

i want to get every <path> where <id_wert> = 1 from a xml file

my query in sql would be "select path from xml where id = 1

<xml_export>
      <id>1<\id>
      <path>\DATEN\00000001.003</path>
</xml_export>
<xml_export>
      <id>2</id>
      <path>\DATEN\00000001.004</path>
</xml_export>
<xml_export>
      <id>1</id>
      <path>\DATEN\00000001.005</path>
</xml_export>
1 Answers

You can locate xml_export parent nodes by child id with desired value and then to get their child path nodes.
As following:

"//xml_export[.//id='1']//path"

In case you want to make it more strict, to search for only cases where id and path are direct children of xml_export the former expression can be changed to be

"//xml_export[./id='1']/path"
Related