XML data is not the easiest to work with. I have seen people get the data out of XML in different ways, but this is how I do it:
- In the above, my XML data is coming from a repeating section in a SharePoint list item. I pass the field that stores this data through a Compose action.
- I add a second Compose action and use this expression to convert the XML to JSON: json(xml(outputs('Compose_Shipment_Items')))
- The expression in both the "Compose Array or Object" action and the Condition is the same. This checks if there is more than 1 item of data in the XML. The expression is length(array(outputs('Compose_JSON')?['RepeaterData']?['Items']?['Item']))
How you process the next steps depends on the condition and whether it is an array or an object and the scheme for the Parse JSON differs depending on the type.
To generate the scheme, you will need to run your flow and copy the output from the Compose JSON action. You can then use the Generate from sample button to generate the scheme. Once you get this far, you can then use JSON Path expressions to get the values from the data. For example: body('Parse_JSON_Object')?['RepeaterData']?['Items']?['Item']?['_c4339a4041ac4f57b5090126c36084d8']?['#text'] when there is one item or items('Apply_to_each_Item')?['_c4339a4041ac4f57b5090126c36084d8']?['#text'] when it is an array with multiple items using the expression builder.