开发者

convert xml into table

I need to conver开发者_StackOverflow社区t an oracle table into xml and then return it to table form.

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


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

e.g.

SELECT warehouse_name warehouse,
   warehouse2."Water", warehouse2."Rail"
   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


Maybe Hyperjaxb is what you need?

It can build databse schemas from XML and vice versa and generate Object Bindings to convert between DB and XML and vice versa:

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

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


You can use XSLT to produce a CSV formated text.


Depending on what you're ultimately trying to do, a simple way is to use XMLSequence() and Table() functions in SQL to convert a nodeset from an Xpath into a rowsource:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜