Convert xml to table

I need to convert oracle table to xml and then return it to table form.

I have converted a table using xmlgen, but I don't know how to reverse the conversion. I am looking for an example of converting an XML file to a table.

+2


source to share


5 answers


Here and here are working examples ...



+3


source


You can create a relational view over an xml table using XMLTABLE syntax.

eg. SELECT warehouse name of warehouse, warehouse 2. "Water", warehouse 2. "Railroad" From warehouses, XMLTABLE ('/ Warehouse' PASSING warehouses.warehouse_spec COLUMNS "Water" varchar2 (6) PATH '/ Warehouse / WaterAccess', "Rail "varchar2 (6) PATH '/ Warehouse / RailAccess') warehouse2;



http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions228.htm

+2


source


Perhaps you need Hyperjaxb?

It can build database schemas from XML and vice versa, and generate object bindings for converting between DB and XML and vice versa:

https://hyperjaxb.dev.java.net/

https://www.hibernate.org/218.html

+1


source


You can use XSLT to generate formatted CSV text.

0


source


Depending on what you are ultimately trying to do, the easy way is to use the XMLSequence () and Table () functions in SQL to convert the node node from the Xpath to a row source:

SELECT
    t.extract( '/bar/@id' ).getNumberVal() ID
FROM
    TABLE( XMLSEQUENCE( 
        XMLTYPE( 
            '<foo><bar id="1" /><bar id="2" /></foo>' 
        ).extract( '//bar' ) 
    ) ) t

      

0


source







All Articles