I'm currently trying to figure out on how to extract some values using plsql from a xml CLOB value that is stored in my database.
My CLOB value looks like the following:
<map>
<entry>
<string>HeaderOne</string>
<string>
<linked-hash-map>
<entry>
<string>ID</string>
<string>81</string>
</entry>
<entry>
<string>Name</string>
<string>John</string>
</entry>
<entry>
<string>SecondName</string>
<string>Smith</string>
</entry>
<entry>
<string>Age</string>
<string>15</string>
</entry>
</linked-hash-map>
</string>
</entry>
<entry>
<string>HeaderTwo</string>
<string>
<linked-hash-map>
<entry>
<string>ID</string>
<string>81</string>
</entry>
<entry>
<string>ZIP</string>
<string>99999</string>
</entry>
<entry>
<string>Gender</string>
<string>M</string>
</entry>
</linked-hash-map>
</string>
</entry>
</map>
I tried using the EXTRAC(xmltype(myclob) method as described here: Extract data from XML Clob using SQL from Oracle Database
However this won't work in my case because the <string>
tag doesn't include an identifier suchs as 'name' or 'key', but instead lists another <string>
entry above the actual value. I.e. <string>ID</string>
is the parameter as one would normally use <string name='ID'>81</string>
where '81' in this case is the actual value I want to be extracted.
The parameters can be listed in any order in the xml, however I know the name from the parameter I wish to extract. So my question is, is there a way to extract for example the value from the <string>Name</string>
entry (in this case 'John', however this can be any value)