Home » Developer & Programmer » JDeveloper, Java & XML » DOM parsing (10G)
DOM parsing [message #474163] Fri, 03 September 2010 05:13 Go to next message
sujeethkannan
Messages: 10
Registered: August 2010
Location: CHENNAI
Junior Member
Hi,
I'm using DOM parser to parse XML satement which is in CLOB column. Node names are displaying correct and data is not displayed..

basically i want to retrive empnuber and emp salary. Any suggestions please?

declare
p xmlparser.parser;
doc xmldom.DOMDocument;

nl xmldom.DOMNodeList;
len1 number;
len2 number;
n xmldom.DOMNode;
e xmldom.DOMElement;
nnm xmldom.DOMNamedNodeMap;
attrname varchar2(100);
attrval varchar2(100);

l_c_lob clob ;
l_v_var varchar2(32000) := '<?xml version="1.0" encoding="utf-8"?>
<EMPETAILS>
<EMP>
<NUM>7369</NUM>
<SAL>180</SAL>
</EMP>
<EMP>
<NUM>7369</NUM>
<SAL>180</SAL>
</EMP>
<EMP>
<NUM>7369</NUM>
<SAL>180</SAL>
</EMP>
</EMPDETAILS>';



begin
dbms_lob.createtemporary(l_c_lob,TRUE);
dbms_lob.OPEN(l_c_lob,dbms_lob.lob_readwrite);
DBMS_LOB.WRITE (l_c_lob, LENGTH (l_v_var), 1,l_v_var);
-- new parser
p := xmlparser.newParser;

xmlparser.setValidationMode(p, FALSE);
xmlparser.parseClob(p,l_c_lob);

doc := xmlparser.getDocument(p);

nl := xmldom.getElementsByTagName(doc, '*');
len1 := xmldom.getLength(nl);

-- loop through elements
for j in 0..len1-1 loop
n := xmldom.item(nl, j);
e := xmldom.makeElement(n);
dbms_output.put_line(xmldom.getTagName(e) || ':');

-- get all attributes of element
nnm := xmldom.getAttributes(n);


if (xmldom.isNull(nnm) = FALSE) then
len2 := xmldom.getLength(nnm);

-- loop through attributes
for i in 0..len2-1 loop
n := xmldom.item(nnm, i);
attrname := xmldom.getNodeName(n);
attrval := xmldom.getNodeValue(n);
dbms_output.put(' ' || attrname || ' = ' || attrval);
end loop;
dbms_output.put_line('');
end if;


end loop;



EXCEPTION
when OTHERS then
RAISE;
end;

Thanks,
kannan
Re: DOM parsing [message #474213 is a reply to message #474163] Fri, 03 September 2010 10:05 Go to previous messageGo to next message
Michel Cadot
Messages: 60062
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Did you succeed to solve your problem at http://www.orafaq.com/forum/m/473366/102589/#msg_473366?

Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

First of all, remove the STUPID when others clause.

Regards
Michel
Re: DOM parsing [message #474214 is a reply to message #474213] Fri, 03 September 2010 10:19 Go to previous message
sujeethkannan
Messages: 10
Registered: August 2010
Location: CHENNAI
Junior Member
Thanks for remembering that.. Its not resolved yet..Work around moved pl/sql block with XMLELEMENT to procedure side and achived the result. Some library file we have to include that it seems..I couldnt get any documentation for that..

Actually compiler command line i'm using is

/opt/oracle/product/prodvers/bin/proc sqlcheck=semantic userid=usrdv42/
usrdv42@DDDDEV40 release_cursor=NO hold_cursor=YES include=/home/a513299/new_wor
k_area/Binaries/dsh00020 include=/home/a513299/new_work_area/Prj_Merge_Release_N
on_Nextgen_R3_2010/DSH/ProC/dsh00020 include=/home/a513299/new_work_area/Prj_Mer
ge_Release_Non_Nextgen_R3_2010/SYS3D/ProC/sys3d_libs include=/usr/include includ
e=/usr/include/sys include=/opt/3d/include include=/opt/3d/include/libxml2 inclu
de=/opt/oracle/product/prodvers/precomp/public include=/opt/oracle/product/prodv
ers/xdk/include iname=/home/a513299/new_work_area/Prj_Merge_Releas
e_Non_Nextgen_R3_2010/DSH/ProC/dsh00020/dsh00020.pc ltype=none oname=dsh00020_$$
.c ; \
/usr/vac/bin/xlc -q32 -qcheck=nonull -qinfo=all:nocnd:noext:nogen:noini
:noobs:noppc:noppt:nopro:notrd:nouni -qextchk -qflttrap -qspnans -qsrcmsg -qfloa
t=dfpemulate -qsaveopt -I/home/a513299/new_work_area/Binaries/dsh00020 -I/home/a
513299/new_work_area/Prj_Merge_Release_Non_Nextgen_R3_2010/DSH/ProC/dsh00020 -I/
home/a513299/new_work_area/Prj_Merge_Release_Non_Nextgen_R3_2010/SYS3D/ProC/sys3
d_libs -I/usr/include -I/usr/include/sys -I/opt/3d/include -I/opt/3d/include/lib
xml2 -I/opt/oracle/product/prodvers/precomp/public -I/opt/oracle/product/prodver
s/xdk/include

Thanks,
Sujeeth
Previous Topic: How to map java objects to Oracle datatypes
Next Topic: XML Processing
Goto Forum:
  


Current Time: Fri Dec 26 18:22:22 CST 2014

Total time taken to generate the page: 0.08387 seconds