An Azure service that automates the access and use of data across clouds without writing code.
Logic App Xpath using dynamic values
I am trying to get the specific xpath value from an HTTP response. I need to get
/UniversalResponse/Data/UniversalShipment/Shipment/DataContext/DataSourceCollection/DataSource/Key where
/UniversalResponse/Data/UniversalShipment/Shipment/DataContext/DataSourceCollection/DataSource/Type = "ForwardingShipment"
Sample HTTP response where I need to get the value:
<UniversalResponse>
<Data>
<UniversalShipment>
<Shipment>
<DataContext>
<DataSourceCollection>
<DataSource>
<Type>ForwardingShipment</Type>
<Key>A0008951</Key>
</DataSource>
</DataSourceCollection>
If I hardcode "ForwardingShipment" in the xpath, I could easily get the value in "Key":
xpath(xml(outputs('Remove_First_Line_In_Universal_Response')),'string(/*[local-name()="UniversalResponse"]/*[local-name()="Data"]/*[local-name()="UniversalShipment"]/*[local-name()="Shipment"]/*[local-name()="DataContext"]/*[local-name()="DataSourceCollection"]/*[local-name()="DataSource"][*[local-name()="Type"]="ForwardingShipment"]/*[local-name()="Key"])')
But the problem is, field "Type" could be any value that will be given from an input. Whenever I replace the type with a compose action ex:
[*[local-name()="Type"]="',outputs('Compose_Type'),'"]
Where "Compose_Type" is just a place value holder for whatever value is in the input, it either says invalid xpath expression or it just literally displays the code as it is:
xpath(xml(outputs('Remove_First_Line_In_Universal_Response')),'string(/*[local-name()="UniversalResponse"]/*[local-name()="Data"]/*[local-name()="UniversalShipment"]/*[local-name()="Shipment"]/*[local-name()="DataContext"]/*[local-name()="DataSourceCollection"]/*[local-name()="DataSource"][*[local-name()="Type"]="ForwardingShipment"]/*[local-name()="Key"])')
Where "ForwardingShipment" is already referenced from a compose action. How should I be able to make the dynamic value work for field "Type"?