Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XMLType Extract Problem With Different Namespaces

littlecatFeb 27 2014 — edited Mar 4 2014

Hi

I require some advice as to how to extract child element from XML fragment, where parent namespace differs from child namespace. I have researched wide and tried many options but have not had success.

Below is sample plsql fragment

  vTheXML:= XMLType('<GeneratedDocument xmlns="http://tempuri.org/">

                                  <FileName xmlns="http://services.dpm.com.au/intelledox/">Test.pdf</FileName>

                                </GeneratedDocument>');

The below successfully returns GeneratedDocument element (ie entire fragment)

  vExtractXML:= vTheXML.extract('/GeneratedDocument', 'xmlns="http://tempuri.org/"');

But none of below work. These return null. I am not sure how to represent the different namespaces in XMLType extract function call

  vExtractXML:= vTheXML.extract('/GeneratedDocument/FileName',  'xmlns="http://services.dpm.com.au/intelledox/"');

  vExtractXML:= vTheXML.extract('/GeneratedDocument/FileName', 'xmlns="http://tempuri.org/" xmlns="http://services.dpm.com.au/intelledox/"');

  vExtractXML:= vTheXML.extract('/GeneratedDocument/FileName',  'xmlns="http://tempuri.org/"');

Below does work, but ideally would like to use more precise XPath criteria

  vExtractXML:= vTheXML.extract('//FileName',  'xmlns="http://services.dpm.com.au/intelledox/"');

Thanks

This post has been answered by odie_63 on Feb 28 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2014
Added on Feb 27 2014
2 comments
573 views