oracle plsql: how to parse XML and insert into table

前端 未结 3 653
后悔当初
后悔当初 2020-12-02 09:35

How to load a nested xml file into database table ?

 

   
       Tom
                


        
3条回答
  •  清歌不尽
    2020-12-02 09:59

    You can load an XML document into an XMLType, then query it, e.g.:

    DECLARE
      x XMLType := XMLType(
        ' 
    
       
           Tom
           
    California Los angeles
    Jim
    California Los angeles
    '); BEGIN FOR r IN ( SELECT ExtractValue(Value(p),'/row/name/text()') as name ,ExtractValue(Value(p),'/row/Address/State/text()') as state ,ExtractValue(Value(p),'/row/Address/City/text()') as city FROM TABLE(XMLSequence(Extract(x,'/person/row'))) p ) LOOP -- do whatever you want with r.name, r.state, r.city END LOOP; END;

提交回复
热议问题