Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why is my XPATH syntax not returing a xmldom.domnodelist of ASSET_DETAIL nodes?

EDWARD HUGHESApr 4 2021

XPATH syntax is not getting a xmldom.domnodelist of ASSET_DETAIL nodes. Uploaded is sample XML and attached is my plsql block. The dbms_xmldom.getlength is always 0. What am I doing wrong??
Builder.txt (20.64 KB)
declare
v_bfile bfile ;
v_clob clob;
v_parser xmlparser.parser;
v_document xmldom.domdocument;

v_nodelist xmldom.domnodelist;
v_node xmldom.domnode;
v_element xmldom.domelement;
v_length number ;
v_i number ;
v_value varchar2 (100) ;
v_node_value varchar2 (500) ;
begin
v_bfile := bfilename ( 'XMLDIR', 'Builder.xml' ) ;

dbms_lob.createtemporary ( v_clob, cache=>false ) ;
dbms_lob.open ( v_bfile, dbms_lob.lob_readonly ) ;
dbms_lob.loadfromfile (
dest_lob => v_clob,
src_lob => v_bfile,
amount => dbms_lob.getlength ( v_bfile )
) ;

dbms_lob.close ( v_bfile ) ;

v_parser := dbms_xmlparser.newparser;
dbms_xmlparser.parseclob ( v_parser, v_clob ) ;
v_document := dbms_xmlparser.getdocument ( v_parser ) ;
dbms_lob.freetemporary ( v_clob ) ;
dbms_xmlparser.freeparser ( v_parser ) ;

v_nodelist := dbms_xslprocessor.selectnodes (
dbms_xmldom.makenode ( v_document ),'/MESSAGE/DEAL_SETS/DEALS_SET/DEALS/DEAL/ASSETS/ASSET/ASSET_DETAIL' ) ;

for i in 0 .. dbms_xmldom.getlength ( v_nodelist ) - 1
loop
v_node := dbms_xmldom.item ( v_nodelist, i ) ;
dbms_xslprocessor.valueof ( v_node, 'AssetType/text()', v_node_value) ;
end loop ;
exception
when others then
dbms_output.put_line ( 'Error '||sqlcode||sqlerrm ) ;
end;
/

Comments
Post Details
Added on Apr 4 2021
3 comments
248 views