So I have an XML that looks a bit like this in an object variable:
<root>
<assetRegistration>Value</assetRegistration>
<assetName>Value</assetName>
<assetId>Value</assetId>
<driverId>Value</driverId>
<driverName>Value</driverName>
<driverGroupId>Value</driverGroupId>
<driverGroupName>Value</driverGroupName>
<assetGroupId>Value</assetGroupId>
<assetGroupName>Value</assetGroupName>
</root>
I am trying to use the XPath function in another variable to get all of the element names inside the root element. I have used many different expressions in the XPath function without any luck.
Here is an example:
xpath(variables('testXML'), '//*/*[name()]')
But this just returns an array with this sort of thing in it:
[
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGFzc2V0UmVnaXN0cmF0aW9uPkxGNjFYR088L2Fzc2V0UmVnaXN0cmF0aW9uPg=="
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGFzc2V0TmFtZT5Vbmtub3duPC9hc3NldE5hbWU+"
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGFzc2V0SWQ+NjA0MjY0PC9hc3NldElkPg=="
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGRyaXZlcklkPjE0MzM0MDwvZHJpdmVySWQ+"
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGRyaXZlck5hbWU+TWljaGFlbCBDYW1wYmVsbDwvZHJpdmVyTmFtZT4="
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGRyaXZlckdyb3VwSWQ+NTUwNmViMDhlNGIwYjc5YTEwMzY4NWNmPC9kcml2ZXJHcm91cElkPg=="
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGRyaXZlckdyb3VwTmFtZT5Fc3NleCBMaWdodGluZzwvZHJpdmVyR3JvdXBOYW1lPg=="
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGFzc2V0R3JvdXBJZD41MjhiODQ3ZGE3ZjQ3ZWRiYmE0NTQyYWU8L2Fzc2V0R3JvdXBJZD4="
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGFzc2V0R3JvdXBOYW1lPkRlLUZpdHRlZDwvYXNzZXRHcm91cE5hbWU+"
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGRhdGU+MjAxNi0wMi0wOVQwNjozNzo0NjwvZGF0ZT4="
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PHN0YXR1cz5lbmRPZkpvdXJuZXk8L3N0YXR1cz4="
},
{
"$content-type": "application/xml;charset=utf-8",
"$content": "PGV2ZW50VHlwZT5zdG9wcGVkPC9ldmVudFR5cGU+"
}
]
Others just return an empty array.
Thanks for any help with this.
I've tried the following XPath expressions as well as others:
'name(/root/*)'
'//*[not(*)]/*[name()]'
'//root/*[not(*)]/*[name()]'
'/root/*/name()'
'/root/*[name()]'
'//root/*[name()]'
I'm expecting an string array of element names. Some of these seem to work in the following link: https://www.freeformatter.com/xpath-tester.html