Given an XML data structure of:
<root>
<a attr="abcd">
<b> test1</b>
<b> test2 </b>
<b> test3 </b>
</a>
<a attr="zyx">
<b> test1 </b>
<b> test2 </b>
<b> test3 </b>
</a>
<a attr="gjui">
<b>test1 </b>
</a>
</root>
I need to normalize this data out:
abcd test1
abcd test2
abcd test3
zyx test1
zyx test2
zyx test1
gjui test1
The issue I am encountering is where there is more than one child for the root.
SELECT xtab.my_attr, xtab.my_attr_values
FROM my_table jx, xmltable('/root/a'
PASSING jx.field_xml
COLUMNS my_attr path '@attr',
my_attr_values path '/a/b')xtab;
Returns
abcd NULL
zyx NULL
gjui test1