On an XML file I use the following XPath expression to get search for a specific value:
I pasted the XML in an online Xpath tester (xpather.com) and tested the Xpath expression:
Here it works, I get the value I expect.
I tried doing the same thing in UiPath Studio:
The result is empty.
Does anyone has a view on what I am doing wrong?
where these steps used inside the XPath
- In the Properties panel, add the variable
XMLString in the XMLString field.
- Add the value
"string(/catalog/book/author/text())" in the XPathExpression field. This expression extracts the text found in the author field from the
- Add the variable
Result in the Result field.
Can you please Check and confirm that your XML is Not defining any namespace e.g.within the upper Elements.
In Case you are unsure Just Log Out the Name ptoperty from the root element and maybe subsequent elements
Thanks for you reply.
Yes, there are indeed namespaces in the XML. Does this need a different Xpath selector?
this should be the explanation for the behaviour. With logging out the element name you can verify if it is in use.
Here is an approach on how to handle without xpath (Me too I do like to work with xpath as well)
In case of your structure is not too complex you may go with the local name trick:
thanks for update via message -
Sometimes it does make sense to start XML Processing learning/experience within a lighweight way:
- working with reduced data / subset of the data
- as in your case maybe removing namespace definitions if there is no name collision
Let us know if further help is required. Happy Automation