Get xml value through xpath

Hello,

as per title, i have an xml in output and an xpath, i should pull out a particular value, how can i handle it?

1 Like

depending on the XML (e.g. defining XML namespaces or not)
In general, we can use the following method:

grafik

xDoc is output from Deserialize XML
grafik

1 Like

Returns this error: xDoc is not a member of System.Xml.Linq.XDocument

pleas show us your implementation along with the Variable definitions or share your XAML uif possible

image

Where xmlDeserialized is output from Deserialize XML and a variable of type Xdocument

xmlDeserialized has to be of datatype XDocument
XPathSelectElement method requires also at least the XPath expression string as method argument

Ensure following as well:
grafik

Please complete always your implementation steps before stating that something is failing. This lets you faster progess

1 Like

ok, was the import of namespace, thank you…

now i have this error:

image

when i try to write in the immediate xDoc.XpathSelectElement(“path”).Value

you cannot use variables which are not existing / or not properly initialized.

So only use the variables which you have set up within your flow

I have the following xpath:

/CC2/TEST_DATA/TEST_CODE/text()

i’m not able to retrieve the following string in TEST_CODE

too many things a mixed up. Can you share your XML file with us? Thanks

1 Like

XMLT.txt (502 Bytes)

this is an example xml, i should retrieve the value of min_code

Thanks in advance

as introducded above:
grafik


grafik

The XML was to repair on the closing DD tag

retrieving the min_code

As an alternate we can also do:
grafik

1 Like

Appreciate your patience.

image

The following error appear following the instructions and fixing the xml.

The expression in log message is the same as your: xDoc.XpathSelectElement(“//MIN_CODE”).Value

where the xDoc var is of xDocument type

debug it and check xDoc. Ensure

  • the correct XML is read in
  • the deserialize XML has an output
  • the output from deserialize XML activity is used for your statement
  • the XPAth is correct

As you can see in the screenshots that the prototyping was working in the immediate panel, somewhere in your flow a small issue is to check and to fix

1 Like

works with the submitted test.xml, not with the original one unfortunately.

That one is inserted inside a soap:Body, do the instructions for getting the information from MIN_CODE change?

Soap is defining namespaces and it was mentioned by:

above on the first answer.

Handling XPath and namespaces have a look here:

we would recommend to share with us all relevant details directly on the begin. So we can reduce ping pongs

@maxena2872 Kindly help us with some test data ?

Thanks
#nK