Different results with Xpath, online and in studio

On an XML file I use the following XPath expression to get search for a specific value:

/StandardBusinessDocument/message/transaction[descendant::additionalTradeItemIdentificationValue[text()="“001293"”]]/entityIdentification/contentOwner/gln/text()[1]

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()[1])" in the XPathExpression field. This expression extracts the text found in the author field from the xml file.
  • Add the variable Result in the Result field.

Cheers @Pascal_Hakkers

Yes, they were
image

@Pascal_Hakkers
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

@ppr
Thanks for you reply.

Yes, there are indeed namespaces in the XML. Does this need a different Xpath selector?

@Pascal_Hakkers
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:

@Pascal_Hakkers
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 :+1: