I am using XML first timer in Postgres and facing an issue. I have below xml in a variable named XMLCONTENT
<?xml version="1.0" encoding="UTF-8"?>
<Actions>
<Action ActionID="90e0dbef-c23a-4fcd-bfa8-75d8bfa2c9e2" />
<Action ActionID="6a1998e1-70f1-4611-992a-7a27e2834c35" />
<Action ActionID="43dd9a91-c6d3-4980-b211-9b3780f04305" />
<Action ActionID="cdf01821-ac28-45a9-abf8-a7d7c9426518" />
<Action ActionID="e86fac8a-84e3-41ba-8bee-c7ffd1ac8ee5" />
<Action ActionID="a68dd878-ba1e-4fd9-b436-cdc15eccffb6" />
<Action ActionID="cd863a5a-83e9-489e-b24d-ff6638c5b190" />
<Action ActionID="720ba9c7-b797-4b2e-913e-11ac3ecd7b7f" />
<Action ActionID="b6b35d0d-938e-45d3-96d1-0c8ca3ad59f3" MessageID="42f40c3a-4426-4506-86c5-222fb03c2114" />
</Actions>
I want to extract details from this XML and I am using below query
Select
Unnest(xpath('//@ActionID',XMLCONTENT)) as ID,
Unnest(xpath('//@MessageID',XMLCONTENT)) as MessageID,
Unnest(xpath('//@Operator',XMLCONTENT)) as Operator
but i am getting wrong output as shown below
MessageID is linked with the wrong actionID. What is the correct way to traverse this XML?
