1 Reply Latest reply: Jan 23, 2012 12:34 PM by "Andrei Costache, Oracle-Oracle" RSS

    XML accessing nodelist elements within nodes

    909760
      Hi

      I have an XML document structure (see example below) that contains an Nodelist element <SPs> of <SP> nodes
      where each <SP> node itself contains a Nodelist element <SetDts> containing <SetDt>
      nodes.

      <?xml version="1.0"?>
      <Int86Data>
      <ReqId>1111111111111111115</ReqId>
      <SPs>
      <SP>
      <MPAN>XX89999997459</MPAN>
      <SetDts>
      <SetDt>
      <SDt>2015-01-10</SDt>
      </SetDt>
      <SetDt>
      <SDt>2015-01-11</SDt>
      </SetDt>
      </SetDts>
      </SP>
      <SP>
      <MPAN>XX89999997451</MPAN>
      <SetDts>
      <SetDt>
      <SDt>2015-01-01</SDt>
      </SetDt>
      <SetDt>
      <SDt>2015-01-02</SDt>
      </SetDt>
      </SetDts>
      </SP>
      </SPs>
      </Int86Data>


      Declarations
      SP_nl dbms_xmldom.DOMNodeList;
      SP_n dbms_xmldom.DOMNode;

      SetDt_nl dbms_xmldom.DOMNodeList;
      SetDt_n dbms_xmldom.DOMNode;

      Assuming have parsed the XML into a document called l_doc, can now successfully can get a list of the SP nodes
      as follows:

      SP_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/Int86Data/SPs/SP');

      and get a SP node (the first in this case) from the SP_nl nodelist

      SP_n := dbms_xmldom.item(SP_nl, 0);

      I now have the first SP node in SP_n. My question is What is the syntax for getting the SetDts NodeList
      out of parent SP_n node.

      I have tried the following but get error - ORA-01405: fetched column value is NULL

      SetDt_nl := dbms_xslprocessor.selectNodes(SP_n,'/SetDts/SetDt')

      Help Appreciated

      Dave McDonald