David GROSPELIER
David GROSPELIER

Reputation: 832

Logic App xpath - how can I get the value without the json syntax?

I execute an xpath function in my Logic App to set the value of a variable. The result is a guid and the variable is formatted as [""]. I want to use this variable in a body message sent to an http endpoint and when I use the variable content, it sent the [""] but I need just to send the . I'm a bit lost here because I don't know how to extract only the Json value of this variable... Thanks.

Upvotes: 1

Views: 1832

Answers (2)

Lathik Kumar N
Lathik Kumar N

Reputation: 23

when you need only one value without any filters this will work. document_url: is the XML tag, here the path to the node is not required.

xpath(xml(Body()),'//document_url/text()') ------- returns all the values
xpath(xml(Body()),'//document_url/text()')[0] ------ returns only the first value

Upvotes: 0

Szymon Wylezol
Szymon Wylezol

Reputation: 1466

The result of the xpath function is a json array of XML nodes matching your xpath expression. If you are only expecting a single node, you can use the @first function to reference it

"@first(xpath(...))"

Upvotes: 3

Related Questions