Tom Schulte
Tom Schulte

Reputation: 439

Expression to read XML attribute value in Logic Apps

In a Logic Apps For Each, I am iterating over part of an XML document that has, in part:

<Part ref="1">

I want to read out the attribute value only. In this case, "1". I have tried:

xpath(xml(item()),'Part/@ref')

and I get

["ref=\"1\""]

With

first(xpath(xml(item()),'Part/@ref'))

I get

ref="1"

I have tried incorporating string() and value() functions to no avail. What is the proper way to read out just the value?

Upvotes: 1

Views: 4053

Answers (2)

felixmondelo
felixmondelo

Reputation: 1474

You have to use this expression in Code View:

@xpath(xml(item()), 'string(/*[local-name()=\"Part\" and namespace-uri()=\"\"]/@*[local-name()=\"ref\" and namespace-uri()=\"\"])')

Upvotes: 0

Gilles Qu&#233;not
Gilles Qu&#233;not

Reputation: 185106

Try this expression :

'string(//Part/@ref)'

Upvotes: 3

Related Questions