Execute x path activity with namespace

Hi, I have found this topic useful but I thought my scenario might add value.

I was trying to make XPATH work for an XML document that had a namespace, but no short name.
A simplified form of the XML is:

<?xml version="1.0" encoding="utf-8"?> David Martin david.martin@ether-solutions.co.uk

I struggled to XPATH to work, as the namespace did not have a shortname e.g. abc

The solution which I hope might help others, is that once the XML file had been read into the string variable - myXMLString, as well as being processed with XPATH, it can also be edited without impacting the XML on the file system. Therefore, a simple string Replace, to remove the namespace e.g. Replace(“xmlns=”“https://www.myite.uk/test”“”,“”)

This simplifies the XML and XPATH works perfectly with the updated string variable. Seems obvious with hindsight but not so apparent when you looking at the source XML file on the file system.

“string(/OrderAcknowledgement/header/yourname/text()[1])”

1 Like