Parse XML Elements/Attributes from CLOB into Oracle Table
434021Jun 2 2006 — edited Jun 5 2006Hi!
I have an XML file (loaded into a CLOB) which I need to parse and have each individual element and attribute inserted into an oracle table for manipulation.
Eg: XML File...
<PERSON>
<PER_ID changed="1">1</PER_ID>
<SURNAME changed="1">MARTIN</SURNAME>
<ADDRESS>
<STREET_NO changed="1">1</STREET_NO>
<POSTCODE changed="1">LE3 8RA</POSTCODE>
</ADDRESS>
</PERSON>
There will only ever be one address.
From this I need to extract
* PER_ID and related changed attribute
* SURNAME and related changed attribute
* STREET_NO and related changed attribute
* POSTCODE and related changed attribute
and insert a single record into the table below:
CREATE TABLE PERSON AS
( PER_ID VARCHAR2(10)
, ID_CHANGED VARCHAR2(1)
, SURNAME VARCHAR2(30)
, ID_CHANGED VARCHAR2(1)
, STREET_NO VARCHAR2(5)
, ID_CHANGED VARCHAR2(1)
, POSTCODE VARCHAR2(10) );
Any assistance/advice would be very much appreciated. I've tried using DBMS_XMLSave / DBMS_XMLStore which works great at pulling in elements (PER_ID, SURNAME, etc) straight into the table but doesn't look at the changed attributes, and I need both.
Thanks a million in advance to anyone who can crack this!!
Jay