Load Xml in oracle (SQL LOADER)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunsom
    New Member
    • Mar 2008
    • 11

    Load Xml in oracle (SQL LOADER)

    i have written a sql loader script given below....



    load data
    infile 'contact1.xml' "str '</CONTACT>'"
    truncate

    into table XmlTest
    (
    dummy filler terminated by ">",
    Location_id enclosed by "<Location_ id>" and "</Location_id>",
    fname enclosed by "<fname>" and "</fname>",
    lname enclosed by "<lname>" and "</lname>"
    )


    the content of the contact1.xml is given below.....
    <CONTACT>
    <Location_id> 1</Location_id>
    <fname>Robert </fname>
    <lname>Jones</lname>
    </CONTACT>
    <CONTACT>
    <Location_id> 1</Location_id>
    <fname>Robert </fname>
    <lname>Jones</lname>
    </CONTACT>



    the script works fine for the given xml... but if one of the tag in the xml is changed to below syntax....
    <CONTACT Location_id="1" >
    <fname>Robert </fname>
    <lname>Jones</lname>
    </CONTACT>
    <CONTACT Location_id="1" >
    <fname>Robert </fname>
    <lname>Jones</lname>
    </CONTACT>

    the script fails....
    what modification is required in the script to read such xml...Kindly Help!!
Working...