Skip to Main Content

XMLTABLE : Convert XML Data into Rows and Columns using SQL

Piero MesticiAug 7 2018 — edited Aug 8 2018

Hall Everybody,

I am using the XMLTABLE , following the blog:

https://oracle-base.com/articles/misc/xmltable-convert-xml-data-into-rows-and-columns-using-sql

I am having the following issue:

IF I store in the DB the following xml file:

<?xml version="1.0" encoding="UTF-8" ?><result xmlns:def="http://www.aaaa.int" xsi:type="def:result" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.aaaa.int"><filed1>vaulefiled1</field1></result>

then the below query is working:

SELECT xt.*

FROM   aadba.xml_tab x,

       XMLTABLE(

       XMLNamespaces('http://www.aaaa.int' as "def",  'http://www.w3.org/2001/XMLSchema-instance' as "xsi"),

       '/'

         PASSING x.xml_data

         COLUMNS

           colum1 VARCHAR2(140)  PATH '/result/field1',

         ) xt

I get the valuefield1 in a column.

Instead if I store in the DB the following xml file

<?xml version="1.0" encoding="UTF-8" ?><result xmlns:def="http://www.aaaa.int" xsi:type="def:result" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.aaaa.int"><filed1 xmlns="http://www.nato.aaaa.int">vaulefiled1</field1></result>

The previous query return null instead of valuefield1.

Could someone support me how to tune the sql command?

I am using Oracle DB 12c .

Regards

This post has been answered by Paulzip on Aug 7 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Sep 4 2018
Added on Aug 7 2018
7 comments
420 views