I want extract list of namespaces from my root element in Oracle PLSQL My xml is for example: (In real it can be very big)
<my_xml xmlns="http://example.com/ns1" xmlns:foo="http://example.com/ns2">
<aaa></aaa>
<myelement>
<foo:/bbb>
</myelement>
</my_xml>
I need it because I didn't know namespaces befere I receive the xml. It's automaticaly serialised and random. I need know namespaces to extract element "my_element" from xml. Thx for help.
I expected result as varchar2 variable with all namespaces:
"xmlns="http://example.com/ns1" xmlns:foo="http://example.com/ns2""
I tried what I know, but dbms_xmldom.getNamespace get me only first namespace of DMBSXMLemement. I can't acces to namespaces as to atributes. I want some nice standard solution. I know I can do it by some substr, instr() etc. I did't know if regular expressions are the good idea?
By mixing DBMS_XMLDOM functionality and REGEXP_SUBSTR, you eventually have a solution:
Adapt to your further needs.