XML DOM Parser Error
402192Aug 26 2003 — edited Sep 19 2003Hi All,
I am trying to a parse an XML File whose contents are given below:
<?xml version="1.0"?>
<inquiryresult sessionname="TheDataEnquiry" code="0" subcode="0">
<indexqueryresult code="0" subcode="0" queryname="AISClient range query">
<item objectname="Ncompass_SVS" mediastatus="m">
<rfield name="Amount" value="79427"/>
<rfield name="PostingDate" value="20030708"/>
<rfield name="Account" value="79427"/>
<rfield name="DRN" value="79427"/>
</item>
</indexqueryresult>
</inquiryresult>
In the above code i have to retrieve the "name" and "value" attributes of <rfield/> tag in each <item/>element.
The PL/SQL Procedure i used for data extraction is:
CREATE OR REPLACE PROCEDURE ParseXMLFile(xmlfile varchar2)
IS
p xmlparser.parser;
doc xmldom.DOMDocument;
nl2 xmldom.DOMNodeList;
nl3 xmldom.DOMNodeList;
n3 xmldom.DOMNode;
n4 xmldom.DOMNode;
e xmldom.DOMElement;
len2 number;
len3 number;
attrname varchar2(100);
attrval varchar2(100);
BEGIN
-- new parser
p := xmlparser.newParser;
-- parse input file
xmlparser.parse(p, xmlfile);
-- get document
doc := xmlparser.getDocument(p);
-- Free resources associated with the Parser as now it is no longer needed.
xmlparser.freeParser(p);
nl2 := xmldom.getElementsByTagName(doc, 'item');
len2 := xmldom.getLength(nl2);
-- loop through elements of item
FOR k IN 0..len2-1 LOOP
n3 := xmldom.item(nl2, k);
nl3 := xmldom.getElementsByTagName(xmldom.makeElement(n3), 'rfield');
len3 := xmldom.getLength(nl3);
-- loop through elements of rfield
FOR l IN 0..len3-1 LOOP
n4 := xmldom.item(nl3, l);
attrname := xslprocessor.valueOf(n4, '@name');
attrval := xslprocessor.valueOf(n4, '@value');
END LOOP;
END LOOP;
END;
But as soon I Parse an XML File greater than 10 MB, it takes a lot of time and gives me the java out of memory error.
Please advise me whether the above method I use to extract data from the XML file is efficient or not.
Thank You,
SUNIL BABU