Skip to main content
New Participant
Dec 19, 2024 5:31 AM UTC
Question

How to retrieve X path(not the value) from an XML file.

Hi people,

I have requirement where i need to find the X path of an XML file. We have functions to retrieve a value using the X path. But our requirement is retrieve the X path instead of the value, So that the user will use that and cross verify the xml file whether its matching. Here is an example.

Input:

<Document>
<customer>
<details>
<name>xyz</name>
<address>abc</address>
<contact>
<phone>45667778</phone>
<employee>
<company>
<department>
<id>6786</id>
</department>
</company>
</employee>
</contact>
</details>

</customer>
</Document>


Output:

for Retrieving the name XYZ this would be the X path

"<Document><customer><details><name>" this is actual output we require

And this is the output we need for nested X path.

"<Document><customer><details> <contact><employee><company><department><id>"

3 replies

stefanhelzle0001
Brainy
Dec 19, 2024 8:19 AM UTC

The whole idea of xPath is, no know the path where to look for data beforehand. If you do not know the structure of the XML, I do not know of any easy way to somehow find specific nodes, values, or paths in it.

New Participant
Dec 19, 2024 1:28 PM UTC

Is there any built-in function or third party plug-in which might be of any help in this case.
The structure of the XML is dynamic in nature, hence the issue.

mathieud0001
Genius
Dec 19, 2024 1:30 PM UTC