Parse XML in PL/SQL

I need help with parsing xml data in PL/SQL. I was able to read the attribute name & values but not able to read the element text.Any help is greatly appreciated.Following is the anonymous block and the desired output -
Declare
nl xmldom.DOMNodeList;
len1 number;
len2 number;
n xmldom.DOMNode;
e xmldom.DOMElement;
nnm xmldom.DOMNamedNodeMap;
attrname varchar2(100);
attrval varchar2(100);
doc xmldom.DOMDocument;
p xmlparser.Parser;
in_xml clob;
begin
-- get all elements
p := xmlparser.newParser;
in_xml := '<?xml version="1.0" encoding="utf-8"?>
<Issue>
<T_ISSUE_TITLE ID = "1">Test Issue</T_ISSUE_TITLE>
<T_ISSUE_DESC ID = "2">Update Test Issue</T_ISSUE_DESC>
<STATUS ID = "3">2</STATUS>
<ISSUE_SD ID = "4">07/09/10</ISSUE_SD>
<ISSUE_ED ID = "5">09/09/10</ISSUE_ED>
<CREATE_DT ID = "6">07/09/10</CREATE_DT>
<CREATE_USER_ID ID = "7">John</CREATE_USER_ID>
<LST_UPD_USER_ID ID = "8">John</LST_UPD_USER_ID>
</Issue>';
xmlparser.parseClob(p,in_xml);
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);
len2 := xmldom.getLength(nnm);
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);
--dbms_output.put_line(n);
attrname := xmldom.getNodeName(n);
attrval := xmldom.getNodeValue(n);
dbms_output.put_line(' ' || attrname || ' = ' || attrval);
end loop;
end if;
end loop;
end;
/** Output
Issue:
T_ISSUE_TITLE:
ID = 1, Test Issue
T_ISSUE_DESC:
ID = 2, Update Test Issue
STATUS:
ID = 3, 2
ISSUE_SD:
ID = 4, 07/09/10
ISSUE_ED:
ID = 5, 09/09/10
CREATE_DT:
ID = 6, 07/09/10
CREATE_USER_ID:
ID = 7, John
LST_UPD_USER_ID:
ID = 8, John
Thank You.

Use dbms_xslprocessor.valueOf and dbms_xmldom.getnodevalue to get the value of node
eg: l_doc is paresed XML doc with nodes as partdetails and part
declare
  l_n       dbms_xmldom.DOMNode;
  l_nl      dbms_xmldom.DOMNodeList;
l_partname varchar2(100);
begin
---parsing code--
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part');
FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
  l_n := dbms_xmldom.item(l_nl, cur_emp);
  dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname);
dbms_output.put_line(l_partname);
end loop;
end;Edited by: SBH on Jul 13, 2010 11:06 AM

Similar Messages

  • How to parsing xml data in sql statement??

    Hi friends, I have a table which contain column as clob ,stores in xml format, for example my column contain xml data like this
    <Employees xmlns="http://TargetNamespace.com/read_emp">
       <C1>106</C1>
       <C2>Harish</C2>
       <C3>1998-05-12</C3>
       <C4>HR</C4>
       <C5>1600</C5>
       <C6>10</C6>
    </Employees>
      Then how to extract the data in above xml column data using SQL statement...

    Duplicate post
    How to parsing xml data in sql statement??

  • Parse XML in PL/SQL need help

    Hi All,
    I'm new to PL/SQL. I need to call a web service from within the PL/SQL and then need to parse the response XML. I was able to call the web service and now I have returned SOAP response XML in CLOB. I searched on google for way to parse this XML and create some kind of list or array or collection with all the values so that later on that collection or array can be used in displaying the data or storing the data, but I couldn't found the right information, rather I got very confused.
    Please help me in parsing this XML and creating some kind collection or array for later use.
    Thanks
    XML is
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
    <getMemberResponse effectiveDate="1970-10-01" endDate="2010-12-31" xmlns="http://abc.org/schema/Member/GetMember/V1">
    <responseHeader xmlns="http://abc.org/schema/common/v1">
    <serviceVersion>2.0.1</serviceVersion>
    <actionRequested AR="QUERY" xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/common/v1" xmlns:v12="http://abc.org/schema/common/v1">
    <v11:transactionName>GetMemberRequest</v11:transactionName>
    </actionRequested>
    <requestResults>
    <resultStatus>Success</resultStatus>
    <resultCodes>
    <resultCode TYPE="HIPAA">00000</resultCode>
    <resultCode TYPE="LEGACY">00000</resultCode>
    <resultCode TYPE="SDI">00000</resultCode>
    </resultCodes>
    <resultMessage>Success</resultMessage>
    </requestResults>
    <accounting xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/datatypes/v1" xmlns:v12="http://abc.org/schema/common/v1">
    <transactionId>ec3542e7-3191-430c-bd69-69dd5d18bf75</transactionId>
    <v12:timeStamp>2011-05-23T11:52:22</v12:timeStamp>
    </accounting>
    </responseHeader>
    <requestID>ec3542e7-3191-430c-bd69-69dd5d18bf75</requestID>
    <memberDetails xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/datatypes/v1" xmlns:v12="http://abc.org/schema/common/v1">
    <v1:ids>
    <v1:id memberIdType="SSN">00000000</v1:id>
    <v1:id memberIdType="PARTYID">111111</v1:id>
    <v1:id memberIdType="PARTYNUMBER">222222</v1:id>
    </v1:ids>
    <v1:demographics>
    <v1:memberDemographicType effDate="2010-05-09" maintType="UPDATE">
    <v1:name>
    <v1:nameDetails>
    <v11:firstName>Keith</v11:firstName>
    <v11:middleName>M</v11:middleName>
    <v11:lastNames>
    <v11:lastName>
    <v11:name>Thompson</v11:name>
    </v11:lastName>
    </v11:lastNames>
    <v11:formattedName>Keith M Thompson</v11:formattedName>
    </v1:nameDetails>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
    </v1:name>
    <v1:birthDate>1954-12-24</v1:birthDate>
    <v1:genderTypeCode>Male</v1:genderTypeCode>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
    </v1:memberDemographicType>
    </v1:demographics>
    <v1:originalContractEffDate>2010-04-01</v1:originalContractEffDate>
    <v1:addresses>
    <v1:address maintType="QUERY">
    <v1:location addresseeType="MEMBER" effDate="1901-01-01" endDate="9999-12-31" locationUseType="HOME" primaryPerType="Y">
    <v11:addressLines>
    <v11:addressLine>BAY VIEW AVENUE</v11:addressLine>
    </v11:addressLines>
    <v11:cityName>PLYMOUTH</v11:cityName>
    <v11:stateCode>TX</v11:stateCode>
    <v11:postalCode>58654</v11:postalCode>
    </v1:location>
    <v1:createDate>2011-05-23T11:52:22</v1:createDate>
    <v1:updateDate>2011-05-23T11:52:22</v1:updateDate>
    </v1:address>
    <v1:address maintType="QUERY">
    <v1:location addresseeType="SUBSCRIBER" effDate="1901-01-01" endDate="9999-12-31" locationUseType="HOME" primaryPerType="Y">
    <v11:addressLines>
    <v11:addressLine>AY VIEW AVENUE</v11:addressLine>
    </v11:addressLines>
    <v11:cityName>PLYMOUTH</v11:cityName>
    <v11:stateCode>TX</v11:stateCode>
    <v11:postalCode>58654</v11:postalCode>
    </v1:location>
    <v1:createDate>2011-05-23T11:52:22</v1:createDate>
    <v1:updateDate>2011-05-23T11:52:22</v1:updateDate>
    </v1:address>
    </v1:addresses>
    <v1:policies>
    <v1:policy effDate="2010-04-01" maintType="ADD" type="MEMBER">
    <v1:ids>
    <v1:id type="MEMBERID">CPIT000456</v1:id>
    <v1:id type="POLICY">CPIT</v1:id>
    </v1:ids>
    <v1:contractType>F</v1:contractType>
    <v1:dependentType>01</v1:dependentType>
    <v1:offerings>
    <v1:offering offeredBy="abc" offeringIdType="INSURANCE_TYPE" selected="Y">
    <v1:offeringId>IV</v1:offeringId>
    </v1:offering>
    <v1:offering effDate="2010-04-01" maintType="ADD" offeredBy="abc" offeringIdType="BOC" selected="Y">
    <v1:offeringId>GK</v1:offeringId>
    <v1:recordInfo>
    <v1:internalRecId>82326287</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-05-09T14:23:17</v1:updateDate>
    </v1:offering>
    </v1:offerings>
    <v1:customer>
    <v1:relation type="EMPLOYMENT">
    <v1:customer>
    <v1:id idType="ACCOUNTID">C11204</v1:id>
    <v1:id idType="DIVISION">0208290000</v1:id>
    <v1:customerName>BC Group</v1:customerName>
    </v1:customer>
    </v1:relation>
    </v1:customer>
    <v1:physicianRelations>
    <v1:physicianRelation effDate="2010-04-01" endDate="9999-12-31" type="PCP">
    <v1:ids>
    <v1:id type="NPI">0</v1:id>
    <v1:id type="AFFILIATIONID">1313 0025</v1:id>
    <v1:id type="PROVIDERID">1313</v1:id>
    <v1:id type="TIN">0</v1:id>
    </v1:ids>
    <v1:recordInfo>
    <v1:internalRecId>98151812</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-10-23T01:10:13</v1:createDate>
    <v1:updateDate>2010-10-23T01:10:13</v1:updateDate>
    </v1:physicianRelation>
    </v1:physicianRelations>
    <v1:maintainReasonCode>AC</v1:maintainReasonCode>
    <v1:recordInfo>
    <v1:internalRecId>82326286</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-05-09T14:23:17</v1:updateDate>
    </v1:policy>
    <v1:policy effDate="2010-04-01" maintType="QUERY" type="SUBSCRIBER">
    <v1:ids>
    <v1:id type="POLICY">CPIT</v1:id>
    </v1:ids>
    <v1:hashCode>82326284</v1:hashCode>
    <v1:contractType>F</v1:contractType>
    <v1:maritalStatus>UNKNOWN</v1:maritalStatus>
    <v1:offerings>
    <v1:offering effDate="2010-04-01" maintType="QUERY" offeredBy="abc" offeringIdType="INSURANCE_TYPE" selected="Y">
    <v1:offeringId>IV</v1:offeringId>
    <v1:recordInfo>
    <v1:internalRecId>82326285</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2011-01-20T04:53:52</v1:updateDate>
    </v1:offering>
    </v1:offerings>
    <v1:customer>
    <v1:relation type="EMPLOYMENT">
    <v1:customer>
    <v1:id idType="ACCOUNTID">C11204</v1:id>
    <v1:id idType="DIVISION">0208290000</v1:id>
    <v1:customerName>BC Group</v1:customerName>
    </v1:customer>
    </v1:relation>
    </v1:customer>
    <v1:maintainReasonCode>AC</v1:maintainReasonCode>
    <v1:recordInfo>
    <v1:internalRecId>82326284</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2011-01-20T04:53:52</v1:updateDate>
    </v1:policy>
    </v1:policies>
    <v1:recordInfo>
    <v1:internalRecId>8364745</v1:internalRecId>
    <v1:objectVersionNo>1</v1:objectVersionNo>
    </v1:recordInfo>
    <v1:restrictedMemberIndicator>N</v1:restrictedMemberIndicator>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
    </memberDetails>
    </getMemberResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    Hi A_Non,
    Thanks so much for giving me the hint about that "text()" in XPath.
    I have new question for you with same XML I'm parsing right now.
    I have extracted a part(Policies) of whole XML and put it in one XMLTYPE variable. Below is that part XML.
    My question is I need to look only into that policy which is active right now. In the <policy> tag there are two attributes "effDate" and "endDate". "effDate" tag will always be there for every policy and for all inactive policies also "endDate" will be there always. Problem is with the active ones, "endDate" may or may not be there. If "endDate" is there so it will be greater than or equal to sysdate and if it is not there that means it is open ended. I need to fetch only that policy which is active right now and if there is no tag as such that means member is not active as of today.
    If "endDate" attribute is there then I think below XPath will work, but I'm not sure about how to handle when "endDate" attribute is not there.
    /d:policies/d:policy[@type="MEMBER" and number(translate(@effDate,"-",""))<=number(translate("'||l_currDate||'","-","")) and number(translate(@endDate,"-",""))>=number(translate("'||l_currDate||'","-",""))]I have Oracle 10.1.0.4, in this in XPath comparison operators are not working so I'm using XPath functions.
    Here is the XML
    <v1:policies>
       <v1:policy effDate="1999-05-01" endDate="1999-12-31" maintType="ADD" type="MEMBER">
           <v1:ids>
               <v1:id type="MEMBERID">SDF000414600</v1:id>
               <v1:id type="POLICY">SDF0004146</v1:id>
           </v1:ids>
           <v1:contractType>F</v1:contractType>
           <v1:dependentType>01</v1:dependentType>
           <v1:offerings>
               <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
                   <v1:offeringId>IH</v1:offeringId>
               </v1:offering>
               <v1:offering effDate="1999-05-01" endDate="1999-12-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
                   <v1:offeringId>HA</v1:offeringId>
                   <v1:recordInfo>
                      <v1:internalRecId>39077481</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-05-01T01:27:04</v1:createDate>
                   <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
               </v1:offering>
           </v1:offerings>
           <v1:customer>
               <v1:relation type="EMPLOYMENT">
                   <v1:customer>
                      <v1:id idType="ACCOUNTID">AS35423</v1:id>
                      <v1:id idType="DIVISION">0621730000</v1:id>
                      <v1:customerName>Medical Associates</v1:customerName>
                   </v1:customer>
               </v1:relation>
           </v1:customer>
           <v1:physicianRelations>
               <v1:physicianRelation effDate="1999-05-01" endDate="1999-12-31" type="PCP">
                   <v1:ids>
                      <v1:id type="NPI">0</v1:id>
                      <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                      <v1:id type="PROVIDERID">231231</v1:id>
                      <v1:id type="TIN">0</v1:id>
                   </v1:ids>
                   <v1:recordInfo>
                      <v1:internalRecId>87796651</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-10-22T21:56:44</v1:createDate>
                   <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
               </v1:physicianRelation>
           </v1:physicianRelations>
           <v1:maintainReasonCode>MD</v1:maintainReasonCode>
           <v1:recordInfo>
               <v1:internalRecId>39077480</v1:internalRecId>
           </v1:recordInfo>
           <v1:createDate>2010-05-01T01:27:04</v1:createDate>
           <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
       </v1:policy>
       <v1:policy effDate="2000-01-01" endDate="2000-12-31" maintType="ADD" type="MEMBER">
           <v1:ids>
               <v1:id type="MEMBERID">SDF000414600</v1:id>
               <v1:id type="POLICY">SDF0004146</v1:id>
           </v1:ids>
           <v1:contractType>F</v1:contractType>
           <v1:dependentType>01</v1:dependentType>
           <v1:offerings>
               <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
                   <v1:offeringId>IH</v1:offeringId>
               </v1:offering>
               <v1:offering effDate="2000-01-01" endDate="2000-12-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
                   <v1:offeringId>HA</v1:offeringId>
                   <v1:recordInfo>
                      <v1:internalRecId>39077483</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-05-01T01:27:04</v1:createDate>
                   <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
               </v1:offering>
           </v1:offerings>
           <v1:customer>
               <v1:relation type="EMPLOYMENT">
                   <v1:customer>
                      <v1:id idType="ACCOUNTID">C35423</v1:id>
                      <v1:id idType="DIVISION">0621730000</v1:id>
                      <v1:customerName>Medical Associates</v1:customerName>
                   </v1:customer>
               </v1:relation>
           </v1:customer>
           <v1:physicianRelations>
               <v1:physicianRelation effDate="2000-01-01" endDate="2000-12-31" type="PCP">
                   <v1:ids>
                      <v1:id type="NPI">0</v1:id>
                      <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                      <v1:id type="PROVIDERID">3213213</v1:id>
                      <v1:id type="TIN">0</v1:id>
                   </v1:ids>
                   <v1:recordInfo>
                      <v1:internalRecId>87796652</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-10-22T21:56:44</v1:createDate>
                   <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
               </v1:physicianRelation>
           </v1:physicianRelations>
           <v1:maintainReasonCode>MD</v1:maintainReasonCode>
           <v1:recordInfo>
               <v1:internalRecId>39077482</v1:internalRecId>
           </v1:recordInfo>
           <v1:createDate>2010-05-01T01:27:04</v1:createDate>
           <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
       </v1:policy>
       <v1:policy effDate="2001-01-01" maintType="ADD" type="MEMBER">
           <v1:ids>
               <v1:id type="MEMBERID">SDF000414600</v1:id>
               <v1:id type="POLICY">SDF0004146</v1:id>
           </v1:ids>
           <v1:contractType>F</v1:contractType>
           <v1:dependentType>01</v1:dependentType>
           <v1:offerings>
               <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
                   <v1:offeringId>IH</v1:offeringId>
               </v1:offering>
               <v1:offering effDate="2001-01-01" endDate="2001-03-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
                   <v1:offeringId>HC</v1:offeringId>
                   <v1:recordInfo>
                      <v1:internalRecId>39077485</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-05-01T01:27:04</v1:createDate>
                   <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
               </v1:offering>
           </v1:offerings>
           <v1:customer>
               <v1:relation type="EMPLOYMENT">
                   <v1:customer>
                      <v1:id idType="ACCOUNTID">C35423</v1:id>
                      <v1:id idType="DIVISION">0621730000</v1:id>
                      <v1:customerName>Medical Associates</v1:customerName>
                   </v1:customer>
               </v1:relation>
           </v1:customer>
           <v1:physicianRelations>
               <v1:physicianRelation effDate="2001-01-01" endDate="2001-03-31" type="PCP">
                   <v1:ids>
                      <v1:id type="NPI">0</v1:id>
                      <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                      <v1:id type="PROVIDERID">61232132</v1:id>
                      <v1:id type="TIN">0</v1:id>
                   </v1:ids>
                   <v1:recordInfo>
                      <v1:internalRecId>87796653</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-10-22T21:56:44</v1:createDate>
                   <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
               </v1:physicianRelation>
           </v1:physicianRelations>
           <v1:maintainReasonCode>LE</v1:maintainReasonCode>
           <v1:recordInfo>
               <v1:internalRecId>39077484</v1:internalRecId>
           </v1:recordInfo>
           <v1:createDate>2010-05-01T01:27:04</v1:createDate>
           <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
       </v1:policy>
    </v1:policies>Thanks

  • Importing/Parsing XML using SQL and/or PL/SQL

    What is the recomended way of importing/parsing XML data using SQL and/or PL/SQL?
    I have an XSD that defines the structure of the file, and an XML file that has the content in the appropriate structure. I have parsed (checked) the structure of the XML file using JDOM in my java application, and then passed it to a function in a package on the database as a CLOB.
    What I need to do is parse the contents of the XML file that is passed into the function and extract the values of each XML element so that I can then do some appropriate validation before inserting and committing the data to the database (hence completing the import function).
    A DBA colleague of mine has been experimenting with various ways of acheiving this, but has encountered a number of problems along the way, one of which being that he thinks that it is not possible to parse XML elements that are nested more than four levels deep - is this the case?
    The structure of the XSD/XML that the database function needs to manipulate and import data from is very complex (and recursive by it's nature).
    I would appreciate any suggestions as to how I can achieve the above in the most efficient manner.
    Thanks in advance for your help
    David

    This is the forum for the SQLDeveloper tool. You will get better answers in the SQL and PL/SQL forum, and especially the XML DB forum.
    Oracle has comprehensive and varied support for XML, including a PL/SQL parser.

  • XML using PL-SQL

    Hi All,
    I am trying to use XML for building an application. Is it
    possible to generate page by only using a PL-SQL?
    I know how to generate XML by using PL-SQL.
    --How can I apply XSL document to it?
    Thanks,
    Samir

    The XML Developers kit available on this site at: http://technet.oracle.com/tech/xml/
    contains utilities for parsing XML with PL/SQL and other methods.

  • External Parser - XML to Pipe Delimited - Sql Loader BETTER DBMS_XMLSTORE

    Hi All,
    If I have got data in GIGs in a complex format.
    Can Using an External Java based XML Parser to convert XML to Pipe Delimited FIle and then Using SQL Loader
    BE BETTER THAN
    Using XSL to convert to Oracle <ROWSET> <ROW> Format and using DBMS_XMLSTORE to load data into tables.
    In terms of:
    Performace
    Scalability
    Exception Handling
    Regards....

    Go to the {forum:id=34} forum and look at the second page of the XML DB FAQ Thread (stickied to the top of the posts). While it doesn't compare using external tools to parse XML and load via SQL*Loader, it does talk about better ways to load large amounts of XML into the DB. This is also a good thread on the subject too from that forum, {thread:id=1096784}

  • How to write sql query to parse xml?

    Hi, I am new to this parsing xml. I need to extract value from xml using sql query. Please find the sample xml file. Kindly help me.
    <?xml version="1.0" encoding="UTF-8"?>
    <MaterialUpdates>
      <Materials>
         <SalesOrg>
           <ID>KAR12</ID>
         </SalesOrg>
    </Materials>
    </MaterialUpdates>
    I need to extratct ID value : /MaterialUpdates/Materials/SalesOrg/ID

    Thanks once again, it is working as per your suggestion. One last question .. how about in case of there is multiple nodes.
    Please find sample xml below:
    <?xml version="1.0" encoding="UTF-8"?>
    <MaterialUpdates>
      <Materials>
         <SalesOrg>
           <ID>KAR12</ID>
         </SalesOrg>
         <SalesOrg>
           <ID>KAR13</ID>
         </SalesOrg>
         <SalesOrg>
           <ID>KAR14</ID>
         </SalesOrg>
    </Materials>
    </MaterialUpdates>
    The above mentioned sql query works fine when there is one occurance of SalesOrg - ID, but fails when there is multiple occurance.

  • Parse complex XML in PL/SQL

    have complex XML with depth level 10. I need to parse and store data into tables from XML. I am able to parse simple XML but not complex. Could any body suggest me the required steps to parse complex XML in PL/SQL?

    Based on response from mdrake on this thread:
    Re: XML file processing into oracle
    Reading XML using a schema...
    declare
      SCHEMAURL VARCHAR2(256) := 'http://xmlns.example.org/xsd/testcase.xsd';
      XMLSCHEMA VARCHAR2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
         <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
            <xs:element name="cust_order" type="cust_orderType" xdb:defaultTable="CUST_ORDER_TBL"/>
            <xs:complexType name="groupType" xdb:maintainDOM="false">
                    <xs:sequence>
                            <xs:element name="item" type="itemType" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="id" type="xs:byte" use="required"/>
            </xs:complexType>
            <xs:complexType name="itemType" xdb:maintainDOM="false">
                    <xs:simpleContent>
                            <xs:extension base="xs:string">
                                    <xs:attribute name="id" type="xs:short" use="required"/>
                                    <xs:attribute name="name" type="xs:string" use="required"/>
                            </xs:extension>
                    </xs:simpleContent>
            </xs:complexType>
            <xs:complexType name="cust_orderType" xdb:maintainDOM="false">
                    <xs:sequence>
                            <xs:element name="group" type="groupType" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="cust_id" type="xs:short" use="required"/>
            </xs:complexType>
         </xs:schema>';
      INSTANCE  CLOB :=
    '<cust_order cust_id="12345">
      <group id="1">
        <item id="1" name="Standard Mouse">100</item>
        <item id="2" name="Keyboard">100</item>
        <item id="3" name="Memory Module 2Gb">200</item>
        <item id="4" name="Processor 3Ghz">25</item>
        <item id="5" name="Processor 2.4Ghz">75</item>
      </group>
      <group id="2">
        <item id="1" name="Graphics Tablet">15</item>
        <item id="2" name="Keyboard">15</item>
        <item id="3" name="Memory Module 4Gb">15</item>
        <item id="4" name="Processor Quad Core 2.8Ghz">15</item>
      </group>
      <group id="3">
        <item id="1" name="Optical Mouse">5</item>
        <item id="2" name="Ergo Keyboard">5</item>
        <item id="3" name="Memory Module 2Gb">10</item>
        <item id="4" name="Processor Dual Core 2.4Ghz">5</item>
        <item id="5" name="Dual Output Graphics Card">5</item>
        <item id="6" name="28inch LED Monitor">10</item>
        <item id="7" name="Webcam">5</item>
        <item id="8" name="A3 1200dpi Laser Printer">2</item>
      </group>
    </cust_order>';                
    begin
      dbms_xmlschema.registerSchema
         schemaurl       => SCHEMAURL
        ,schemadoc       => XMLSCHEMA
        ,local           => TRUE
        ,genTypes        => TRUE
        ,genBean         => FALSE
        ,genTables       => TRUE
        ,ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
      execute immediate 'insert into CUST_ORDER_TBL values (XMLTYPE(:INSTANCE))' using INSTANCE;
    end;
    desc CUST_ORDER_TBL
    --SQL> desc CUST_ORDER_TBL
    -- Name                                                                                                                                    Null?    Type
    -- TABLE of SYS.XMLTYPE(XMLSchema "http://xmlns.example.org/xsd/testcase.xsd" Element "cust_order") STORAGE Object-relational TYPE "cust_orderType222_T"
    set autotrace on explain
    set pages 60 lines 164 heading on
    col cust_id format a8
    select extract(object_value,'/cust_order/@cust_id') as cust_id
          ,grp.id as group_id, itm.id as item_id, itm.inm as item_name, itm.qty as item_qty
    from   CUST_ORDER_TBL
          ,XMLTABLE('/cust_order/group'
                    passing object_value
                    columns id   number       path '@id'
                           ,item xmltype      path 'item'
                   ) grp
          ,XMLTABLE('/item'
                    passing grp.item
                    columns id   number       path '@id'
                           ,inm  varchar2(30) path '@name'
                           ,qty  number       path '.'
                   ) itm
    CUST_ID    GROUP_ID    ITEM_ID ITEM_NAME                        ITEM_QTY
    12345             1          1 Standard Mouse                        100
    12345             1          2 Keyboard                              100
    12345             1          3 Memory Module 2Gb                     200
    12345             1          4 Processor 3Ghz                         25
    12345             1          5 Processor 2.4Ghz                       75
    12345             2          1 Graphics Tablet                        15
    12345             2          2 Keyboard                               15
    12345             2          3 Memory Module 4Gb                      15
    12345             2          4 Processor Quad Core 2.8Ghz             15
    12345             3          1 Optical Mouse                           5
    12345             3          2 Ergo Keyboard                           5
    12345             3          3 Memory Module 2Gb                      10
    12345             3          4 Processor Dual Core 2.4Ghz              5
    12345             3          5 Dual Output Graphics Card               5
    12345             3          6 28inch LED Monitor                     10
    12345             3          7 Webcam                                  5
    12345             3          8 A3 1200dpi Laser Printer                2
    17 rows selected.Need at least 10.2.0.3 for performance i.e. to avoid COLLECTION ITERATOR PICKLER FETCH in execution plan...
    On 10.2.0.1:
    Execution Plan
    Plan hash value: 3741473841
    | Id  | Operation                          | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                   |                        | 24504 |    89M|   873   (1)| 00:00:11 |
    |   1 |  NESTED LOOPS                      |                        | 24504 |    89M|   873   (1)| 00:00:11 |
    |   2 |   NESTED LOOPS                     |                        |     3 | 11460 |   805   (1)| 00:00:10 |
    |   3 |    TABLE ACCESS FULL               | CUST_ORDER_TBL         |     1 |  3777 |     3   (0)| 00:00:01 |
    |*  4 |    INDEX RANGE SCAN                | SYS_IOT_TOP_774117     |     3 |   129 |     1   (0)| 00:00:01 |
    |   5 |   COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE |       |       |            |       |
    Predicate Information (identified by operation id):
       4 - access("NESTED_TABLE_ID"="CUST_ORDER_TBL"."SYS_NC0000900010$")
           filter("SYS_NC_TYPEID$" IS NOT NULL)
    Note
       - dynamic sampling used for this statementOn 10.2.0.3:
    Execution Plan
    Plan hash value: 1048233240
    | Id  | Operation               | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT        |                   |    17 |   132K|   839   (0)| 00:00:11 |
    |   1 |  NESTED LOOPS           |                   |    17 |   132K|   839   (0)| 00:00:11 |
    |   2 |   MERGE JOIN CARTESIAN  |                   |    17 |   131K|   805   (0)| 00:00:10 |
    |   3 |    TABLE ACCESS FULL    | CUST_ORDER_TBL    |     1 |  3781 |     3   (0)| 00:00:01 |
    |   4 |    BUFFER SORT          |                   |    17 | 70839 |   802   (0)| 00:00:10 |
    |*  5 |     INDEX FAST FULL SCAN| SYS_IOT_TOP_56154 |    17 | 70839 |   802   (0)| 00:00:10 |
    |*  6 |   INDEX UNIQUE SCAN     | SYS_IOT_TOP_56152 |     1 |    43 |     2   (0)| 00:00:01 |
    |*  7 |    INDEX RANGE SCAN     | SYS_C006701       |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       5 - filter("SYS_NC_TYPEID$" IS NOT NULL)
       6 - access("SYS_NTpzENS1H/RwSSC7TVzvlqmQ=="."NESTED_TABLE_ID"="SYS_NTnN5b8Q+8Txi9V
                  w5Ysl6x9w=="."SYS_NC0000600007$")
           filter("SYS_NC_TYPEID$" IS NOT NULL AND
                  "NESTED_TABLE_ID"="CUST_ORDER_TBL"."SYS_NC0000900010$")
       7 - access("SYS_NTpzENS1H/RwSSC7TVzvlqmQ=="."NESTED_TABLE_ID"="SYS_NTnN5b8Q+8Txi9V
                  w5Ysl6x9w=="."SYS_NC0000600007$")
    Note
       - dynamic sampling used for this statement-----
    -- CLEAN UP
    DROP TABLE CUST_ORDER_TBL purge;
    exec dbms_xmlschema.deleteschema('http://xmlns.example.org/xsd/testcase.xsd');

  • Parsing XML stored in CLOB (PL/SQL)

    Hello,
    I would like to parse XML document like the example below.
    When it is stored in VARCHAR2 column, parsing works well.
    When it is stored in CLOB column, I get error message:
    "ORA-20100: Error occurred while parsing: Invalid char in text."
    The <text> section contains valid characters of ISO-8859-2 encoding.
    If <text> section contains only ASCII compatible characters, parsing works well.
    <?xml version="1.0" encoding="ISO-8859-2"?>
    <body>
    <text> &igrave;&egrave;&oslash;}amiz&ugrave; </text>
    </body>
    Is it a bug? Or where is problem?
    Any help would be appreciated.

    I used such an example to parse several Varchar2 strings in a given DB session:
    BEGIN
    parser := xmlparser.newparser ;
    xmlparser.parsebuffer(parser,xmlout) ;
    domdoc := xmlparser.getDocument(parser) ;
    xmlparser.FREEPARSER(parser) ;
    parser.id := -1 ;
    nodes := xslprocessor.selectNodes(
    xmldom.makenode(domdoc),
    'Positionen/Position') ;
    for i in 1 .. xmldom.getLength(nodes) loop
    node := xmldom.item(nodes,i-1) ;
    -- do s/thing with the node
    end loop ;
    xmldom.freedocument(domdoc) ;
    RETURN(komponenten) ;
    EXCEPTION
    WHEN OTHERS THEN
    if parser.id <> -1 then xmlparser.freeparser(parser) ;
    end if ;
    if domdoc.id <> -1 then xmldom.freedocument(domdoc) ;
    end if ;
    RAISE ;
    END ;
    However, after about 2000 of nodes lists parsed, I get an ArrayIndexOutOfBoundsException from XMLNodeCover. Obviously, I should release the nodes or the nodelist, but I have not found any procedure to do this.
    Pascal

  • Need help on parsing xml file...

    Hi all,
    I need to collect some data from an Xml file using java. I have the following code with me but I am unable to get the required result. I am unable to get the data from the tags belonging to the header and footer elements. Please find the code and the sample xml file below.
    Program to parse XML:
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class JobLogDetails3{
         //No generics
         List myJobs;
         Document dom;
         public JobLogDetails3(){
              //create a list to hold the job objects
              myJobs = new ArrayList();
         public void runJobDetails() {
              //parse the xml file and get the dom object
              parseXmlFile();
              //get each joblog element and create a job object
              parseDocument();
              //Iterate through the list and print the data
              printData();
         private void parseXmlFile(){
              //get the factory
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              try {
                   //Using factory get an instance of document builder
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   //parse using builder to get DOM representation of the XML file
                   dom = db.parse("test.xml");
              }catch(ParserConfigurationException pce) {
                   pce.printStackTrace();
              }catch(SAXException se) {
                   se.printStackTrace();
              }catch(IOException ioe) {
                   ioe.printStackTrace();
         private void parseDocument(){
              //get the root elememt
              Element docEle = dom.getDocumentElement();
              //get a nodelist of <joblog> elements
              NodeList nl = dom.getElementsByTagName("*");
              if(nl != null && nl.getLength() > 0) {
                   for(int i = 0 ; i < nl.getLength();i++) {
                        //get the joblog element
                        Element el = (Element)nl.item(i);
                        //get the joblog object
                        Job J = getJob(el);
                        //add it to list
                        myJobs.add(J);
         * I take an joblog element and read the values in, create
         * an joblog object and return it
         * @param JobEl
         * @return
         private Job getJob(Element JobEl) {
              //for each <joblog> element get text or int values of
              //name ,id, age and name
              String jobServer = getTextValue(JobEl,"server");
              String jobName = getTextValue(JobEl,"name");
              String jobClient = getTextValue(JobEl,"machine_name");
              String jobStart = getTextValue(JobEl,"start_time");
              String jobType = getTextValue(JobEl,"type");
              String jobEnd = getTextValue(JobEl,"end_time");
              String jobSize = getTextValue(JobEl,"new_processed_bytes");
              //Create a new Job with the value read from the xml nodes
              Job J = new Job(jobServer,jobName,jobClient,jobStart,jobType,jobEnd,jobSize);
              return J;
         * I take a xml element and the tag name, look for the tag and get
         * the text content
         * i.e for <employee><name>John</name></employee> xml snippet if
         * the Element points to employee node and tagName is name I will return John
         * @param ele
         * @param tagName
         * @return
         private String getTextValue(Element ele, String tagName) {
              String textVal = null;
              NodeList nl = ele.getElementsByTagName(tagName);
              if(nl != null && nl.getLength() > 0) {
                   Element el = (Element)nl.item(0);
                   textVal = el.getFirstChild().getNodeValue();
              return textVal;
         * Calls getTextValue and returns a int value
         * @param ele
         * @param tagName
         * @return
         private int getIntValue(Element ele, String tagName) {
              //in production application you would catch the exception
              return Integer.parseInt(getTextValue(ele,tagName));
         * Iterate through the list and print the
         * content to console
         private void printData(){
              System.out.println("No of Jobs '" + myJobs.size() + "'.");
              Iterator it = myJobs.iterator();
              while(it.hasNext()) {
                   System.out.println(it.next().toString());
         public static void main(String[] args){
              //create an instance
              JobLogDetails JLD = new JobLogDetails();
              //call run example
              JLD.runJobDetails();
    Job Class
    public class Job {
         private String jobServer;
    private String jobName;
    private String jobClient;
    private String jobStart;
    private String jobType;
    private String jobEnd;
    private String jobSize;
         public Job(){
         public Job(String jobServer,String jobName,String jobClient,String jobStart,String jobType,String jobEnd,String jobSize ) {
              this.jobServer = jobServer;
              this.jobName = jobName;
              this.jobClient = jobClient;
    this.jobStart = jobStart;
              this.jobType = jobType;
    this.jobEnd = jobEnd;
    this.jobSize = jobSize;
         public String getjobServer() {
              return jobServer;
         public void setjobServer(String jobServer) {
              this.jobServer = jobServer;
         public String getjobName() {
              return jobName;
         public void setjobname(String jobName) {
              this.jobName = jobName;
         public String getjobClient() {
              return jobClient;
         public void setjobClient(String jobClient) {
              this.jobClient = jobClient;
    public String getjobStart() {
              return jobStart;
         public void setjobStart(String jobStart) {
              this.jobStart = jobStart;
    public String getjobType() {
              return jobType;
         public void setjobType(String jobType) {
              this.jobType = jobType;
    public String getjobEnd() {
              return jobEnd;
         public void setjobEnd(String jobEnd) {
              this.jobEnd = jobEnd;
    public String getjobSize() {
              return jobSize;
         public void setjobSize(String jobSize) {
              this.jobSize = jobSize;
         public String toString() {
              StringBuffer sb = new StringBuffer();
    sb.append(getjobServer());
              sb.append(",");
    sb.append(getjobName());
              sb.append(",");
              sb.append(getjobClient());
              sb.append(",");
              sb.append(getjobType());
              sb.append(",");
              sb.append(getjobStart());
              sb.append(",");
              sb.append(getjobEnd());
              sb.append(",");
              sb.append(getjobSize());
              sb.append(",");
              return sb.toString();
    Sample XML File:
    <?xml version="1.0" encoding="UTF-16" ?>
    - <joblog>
    <job_log_version version="2.0" />
    - <header>
    <filler>======================================================================</filler>
    <server>Job server: TGBBAK</server>
    <name>Job name: TGBSAP4-SQL-SQL DB Servers S2T - High-Weekly Full Backup</name>
    <start_time>Job started: 26 September 2011 at 01:00:04</start_time>
    <type>Job type: Backup</type>
    <log_name>Job Log: GFD_TGBBAK_71887.xml</log_name>
    <filler>======================================================================</filler>
    </header>
    <media_mount_date>Drive and media mount requested: 26/09/2011 01:00:04</media_mount_date>
    - <media_drive_and_media_info>
    <media_mount_date>Drive and media information from media mount: 26/09/2011 01:00:39</media_mount_date>
    <robotic_library_name>Robotic Library Name: HP 1</robotic_library_name>
    <drive_name>Drive Name: LTO4_2</drive_name>
    <slot>Slot: 43</slot>
    <media_label>Media Label: 000059L</media_label>
    <media_guid>Media GUID: {a6ca0062-7a6f-4b4b-8144-732ca25f2f9d}</media_guid>
    <media_overwrite_date>Overwrite Protected Until: 25/10/2011 19:24:58</media_overwrite_date>
    <media_append_date>Appendable Until: 02/10/2011 14:00:30</media_append_date>
    <media_set_target>Targeted Media Set Name: Weekly Tape</media_set_target>
    </media_drive_and_media_info>
    - <backup>
    <filler>======================================================================</filler>
    <title>Job Operation - Backup</title>
    <append_or_overwrite>Media operation - append.</append_or_overwrite>
    <compression>Compression Type: Hardware [if available, otherwise none]</compression>
    <verify_option>WARNING: The option 'Verify after backup completes' was not selected. Performing a verify operation to make sure that media can be read after the backup has completed is recommended.</verify_option>
    <filler>======================================================================</filler>
    - <machine>
    <machine_name>TGBSAP4.Tetley.Grp</machine_name>
    <info>Network control connection is established between 10.22.2.18:3271 <--> 10.22.2.4:10000</info>
    <info>Network data connection is established between 10.22.2.18:3301 <--> 10.22.2.4:3094</info>
    - <set>
    <set_resource_name>TGBSAP4.Tetley.Grp</set_resource_name>
    <tape_name>Family Name: "Media created 25/09/2011 13:59:55"</tape_name>
    - <volume>
    <display_volume>Backup of "TGBSAP4.Tetley.Grp "</display_volume>
    </volume>
    <description>Backup set #45 on storage media #1 Backup set description: "Weekly Full Backup"</description>
    <backup_type>Backup Method: Full - Back up entire database or filegroup</backup_type>
    <agent_started>Microsoft SQL Server Agent: Started</agent_started>
    <start_time>Backup started on 26/09/2011 at 01:01:45.</start_time>
    - <database>
    <database>Database PRD</database>
    </database>
    - <database>
    <database>Database master</database>
    </database>
    - <database>
    <database>Database model</database>
    </database>
    - <database>
    <database>Database msdb</database>
    </database>
    <end_time>Backup completed on 26/09/2011 at 02:42:25.</end_time>
    - <summary>
    <backed_up_database>Backed up 4 databases</backed_up_database>
    <new_processed_bytes>Processed 573363576542 bytes in 1 hour, 40 minutes, and 40 seconds.</new_processed_bytes>
    <vlm_hist_rateformat2>Throughput rate: 5432 MB/min</vlm_hist_rateformat2>
    </summary>
    <filler>----------------------------------------------------------------------</filler>
    </set>
    </machine>
    </backup>
    - <footer>
    <filler>======================================================================</filler>
    <end_time>Job ended: 26 September 2011 at 02:43:12</end_time>
    <engine_completion_status>Job completion status: Successful</engine_completion_status>
    <filler>======================================================================</filler>
    <completeStatus>19</completeStatus>
    </footer>
    </joblog>

    1. your code does not compile (in your main method you try to create an instance of a class which does not exist).
    2. your XML document is not well formed.
    +[Fatal Error] test.xml:34:74: The content of elements must consist of well-formed character data or markup.+
    org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    Maybe there are other problems but you can start by fixing these.

  • SOAPFaultException: error in msg parsing: xml was empty, didn't parse!

    Using the web service example from http://www.oracle-base.com/articles/10g/utl_dbws-10g.php. Can anyone tell me why I can't call this web service twice within the same database session? The first call seems to work for each session, but the second generates an error.
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE     11.2.0.3.0     Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> CREATE OR REPLACE FUNCTION add_numbers(p_int_1 IN NUMBER,
      2                                         p_int_2 IN NUMBER) RETURN NUMBER AS
      3    l_service sys.utl_dbws.service;
      4    l_call    sys.utl_dbws.call;
      5 
      6    l_wsdl_url        VARCHAR2(32767);
      7    l_namespace       VARCHAR2(32767);
      8    l_service_qname   sys.utl_dbws.qname;
      9    l_port_qname      sys.utl_dbws.qname;
    10    l_operation_qname sys.utl_dbws.qname;
    11 
    12    l_xmltype_in  sys.xmltype;
    13    l_xmltype_out sys.xmltype;
    14    l_return      NUMBER;
    15  BEGIN
    16    l_wsdl_url  := 'http://www.oracle-base.com/webservices/server.php?wsdl';
    17    l_namespace := 'http://www.oracle-base.com/webservices/';
    18 
    19    l_service_qname   := sys.utl_dbws.to_qname(l_namespace,
    20                                               'Calculator');
    21    l_port_qname      := sys.utl_dbws.to_qname(l_namespace,
    22                                               'CalculatorPort');
    23    l_operation_qname := sys.utl_dbws.to_qname(l_namespace,
    24                                               'ws_add');
    25 
    26    l_service := sys.utl_dbws.create_service(wsdl_document_location => urifactory.geturi(l_wsdl_url),
    27                                             service_name           => l_service_qname);
    28 
    29    l_call := sys.utl_dbws.create_call(service_handle => l_service,
    30                                       port_name      => l_port_qname,
    31                                       operation_name => l_operation_qname);
    32 
    33    l_xmltype_in  := sys.xmltype('<?xml version="1.0" encoding="utf-8"?>
    34      <ws_add xmlns="' || l_namespace || '">
    35        <int1>' || p_int_1 || '</int1>
    36        <int2>' || p_int_2 || '</int2>
    37      </ws_add>');
    38    l_xmltype_out := sys.utl_dbws.invoke(call_handle => l_call,
    39                                         request     => l_xmltype_in);
    40 
    41    sys.utl_dbws.release_call(call_handle => l_call);
    42    sys.utl_dbws.release_service(service_handle => l_service);
    43 
    44    l_return := l_xmltype_out.extract('//return/text()').getnumberval();
    45    RETURN l_return;
    46  END;
    47  /
    Function created
    SQL> BEGIN
      2    dbms_output.put_line(add_numbers(1,
      3                                     4));
      4    dbms_output.put_line('first call succeeded');
      5    dbms_output.put_line(add_numbers(1,
      6                                     9));
      7    dbms_output.put_line('second call succeeded');
      8  END;
      9  /
    5
    first call succeeded
    BEGIN
      dbms_output.put_line(add_numbers(1,
                                       4));
      dbms_output.put_line('first call succeeded');
      dbms_output.put_line(add_numbers(1,
                                       9));
      dbms_output.put_line('second call succeeded');
    END;
    ORA-29532: Java call terminated by uncaught Java exception: javax.xml.rpc.soap.SOAPFaultException: error in msg parsing:
    xml was empty, didn't parse!
    ORA-06512: at "SYS.UTL_DBWS", line 404
    ORA-06512: at "SYS.UTL_DBWS", line 401
    ORA-06512: at "GLYODER.ADD_NUMBERS", line 38
    ORA-06512: at line 6

    hi Gyoder      
    Do you resolve this problem?
    Thanks

  • Importing/Parsing XML

    I have posted the following thread in the SQL/PLSQL forum and would appreciate your input as it is realted to XML.
    Re: Importing/Parsing XML using SQL and/or PL/SQL
    Thanks in advance for your help
    David
    Message was edited by:
    David Ferguson

    Hi David, please do visit the XML DB forum. There is an Oracle guy named Mark Drake and he is very good at this stuff. To your questions, yes, Oracle XML DB can handle any type of XML no matter how many levels you have. Check out the XMLTable function in the Oracle XML user's guide and it is pretty powerful. The trick is that it is hard if not impossible to combine singletons and multiples, because multiples require its own handling. I have to deal with this a lot. In some cases, I can use two xmltables, one for the multiples and one for the singlton, repeating the singleton for each of the multiples in one table. In other cases I just do two steps: get the multiples and singltons separately. You will find that using the global temporary table for this type of xml processing comes handy. At our place, some people use BizTalk to "map, orchestrate, factor and re-factor" xml messages from a partner, but I use Oracle XML DB. I have completed all available xml messages (more than 20) in just a short time, but it took the BizTalk consultants almost 5 months to finish one simple xml message! When I say Oracle does a beautiful job, they are not happy so they tell me that I should have been an Oracle salesman.
    Ben

  • Generating XML through PL/SQL

    Hi everyone,
    I got a new task at work, and my task is to generate XML through PL/SQL.
    I am using Oracle 11g database, and SQL Developer 3.0.
    The purpose of this procedure is to upload xml file to a queue, so my BPEL process can access the queue and do what it does.
    This is my first time writing a procedure that generates xml so bear with me.
    Below is a sample of the xml file I received. I need to generate xml file below through PL/SQL. All the information in xml file will need to be retrieved from the database.
    I need your help to start working on this procedure. Your help is very much appreciated.
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Body xmlns:ns1="http://www.ussc.gov/soa/casefile/event/types">
          <caseFileUploadEvent xmlns:xsi="http://www.w3XX.org/2001/XMLSchema-instance"
                               xsi:schemaLocation="http://www.XXXX.gov/soa/casefile/event/types ../xsd/Case_META.xsd"
                               xmlns="http://www.XXXX.gov/soa/casefile/event/types">
             <taskEvent>SUBMIT</taskEvent>
             <defendentDetails>
                <sentensingDate>2008-11-10-05:00</sentensingDate>
                <personDetails>
                   <personNameDetails>
                      <firstName>FIRSTNAME</firstName>
                      <middleName>B</middleName>
                      <lastName>LASTNAME</lastName>
                   </personNameDetails>
                   <dateOfBirth>1969-09-23-04:00</dateOfBirth>
                </personDetails>
             </defendentDetails>
             <documentStatusDetails>
                <otherStatus>
                   <intCode>61</intCode>
                   <description>Other documents included</description>
                </otherStatus>
             </documentStatusDetails>
             <uploadOtherDetails>
                <submissionId>427000447</submissionId>               // NOTE: SUBMISSIONID WILL BE PASSED IN THROUGH THE PROCEDURE TO QUERY ALL THE INFORMATION NEEDED FOR THE XML FILE
                <submissionSessionId>401622</submissionSessionId>
                <submissionMethod>
                   <intCode>1</intCode>
                   <description>WebApplication</description>
                </submissionMethod>
                <submissionReason>
                   <intCode>1</intCode>
                   <description>InitialSubmission</description>
                </submissionReason>
                <district>
                   <intCode>99</intCode>
                   <description>Test District</description>
                </district>
                <caseFileType>
                   <intCode>10</intCode>
                   <description>Individual - Original</description>
                </caseFileType>
                <primaryDocketInfo>
                   <yearYY>5</yearYY>
                   <id>55555</id>
                   <defendentNumber>555</defendentNumber>
                </primaryDocketInfo>
                <PACTSId>55555555</PACTSId>
                <AOJudgeId>
                   <intCode>2512</intCode>
                   <description>FABER, DAVID, A.</description>
                </AOJudgeId>
                <missingCasefile>false</missingCasefile>
                <creator>
                   <firstName>will</firstName>
                   <lastName>smith</lastName>
                   <email>[email protected]</email>
                   <actionDate>2005-09-07T09:48:09.811-04:00</actionDate>
                </creator>
                <lastModifier>
                   <firstName>john</firstName>
                   <lastName>doe</lastName>
                   <email>[email protected]</email>
                   <actionDate>2006-10-03T08:51:21.5-04:00</actionDate>
                </lastModifier>
             </uploadOtherDetails>
          </caseFileUploadEvent>
       </soap:Body>
    </soap:Envelope>procedure below
    procedure upload_process(submission_id number) as
    begin
         -- retrieve information from database based on submission_id (passed in)
         -- generate XML
         -- send xml to queue
    end upload_process;Thanks

    Rooney,
    First of all, I would use Oracle package UTL_DBWS to handle web service calls.
    But if you choose to do all the work yourself to call web service, this is one of the options:
    Since the size of your xml soap request is about 4k, you can just use pl/sql varchar2 variable to construct your xml.
    Example:
    cSoapRequest VARCHAR2(5000);
    BEGIN
    cSoapRequest := '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                             <soap:Body xmlns:ns1="http://www.ussc.gov/soa/casefile/event/types">
                             <caseFileUploadEvent xmlns:xsi="http://www.w3XX.org/2001/XMLSchema-instance"
                             xsi:schemaLocation="http://www.XXXX.gov/soa/casefile/event/types ../xsd/Case_META.xsd"
                             xmlns="http://www.XXXX.gov/soa/casefile/event/types">';
    FOR recRow IN <your cursor> LOOP
        cSoapRequest := cSoapRequest || '<dateOfBirth>'|| TO_CHAR(recRow.DOB,'YYYY-MM-DD HH:MI' )|| '</dateOfBirth>';
    END LOOP;
    ...Then use package utl_http to send the request and recieve response.
    Google pl/sql webservice,
    Here is one:
    Calling Web Service from PL/SQL (ORA-31011: XML parsing failed)
    Hope this will give you an idea.
    Thomas

  • Error parsing XML license file

    i need assistance while installing WebLogic 5.1 Evaluation version on my NT Server and i also registered and downloaded the key for that but still my server is not functioning as it gives me a license file error in java.....
    The error is as follows....
    *****Start********
    weblogic.common.LicenseCorruptException: Error parsing XML license file. [java.util.EmptyStackException
    at java.util.Stack.peek(Stack.java, Compiled Code)
    at java.lang.Exception.<init>(Exception.java, Compiled Code)
    at java.lang.RuntimeException.<init>(RuntimeException.java, Compiled Code)
    at java.util.EmptyStackException.<init>(EmptyStackException.java, Compiled Code)
    at java.util.Stack.peek(Stack.java, Compiled Code)
    at weblogic.xml.license.Handler.characters(Handler.java:63)
    at weblogic.xml.license.BaseParser.sendCharacters(BaseParser.java:120)
    at weblogic.xml.license.BaseParser.eatComment(BaseParser.java, Compiled Code)
    at weblogic.xml.license.WEBLOGICLICENSESParser.parse(WEBLOGICLICENSESParser.java, Compiled Code)
    at weblogic.xml.license.BaseParser.parse(BaseParser.java, Compiled Code)
    at weblogic.common.internal.LicenseInfo.loadXML(LicenseInfo.java, Compiled Code)
    at weblogic.common.internal.ServerUtil.initLogging(ServerUtil.java, Compiled Code)
    at weblogic.common.internal.ServerUtil.initLogging(ServerUtil.java:82)
    at weblogic.common.internal.ServerUtil.<clinit>(ServerUtil.java:75)
    at weblogic.t3.srvr.T3Srvr.checkAccess(T3Srvr.java:883)
    at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:822)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.Server.startServerDynamically(Server.java:99)
    at weblogic.Server.main(Server.java:65)
    at weblogic.Server.main(Server.java:55)
    *****End******
    The License file i downloaded was from the website as i was told to do so...
    I would really appreaciate your help in the above error to solve my problem as i am trying to learn weblogic and am stuck at the very bigenning..
    Thanx a lot...

    If you can, upgrade your jdbcKona/MSSQLserver4 driver to
    at least version 4.5.1.2.
    Branka Billante wrote:
    >
    I am trying to debug my code in VisualCafe and I get the following
    error:
    java.sql.SQLException: java.sql.SQLException: License Problem:
    The following applies to holders of standard BEA/WebXpress licenses:
    weblogic.d.h: Error parsing XML license file. [java.lang.Exception:
    java.lang.ClassCastException: weblogic.xml.license.WEBLOGICLICENSES
    at weblogic.i.g.a(Unknown Source)
    at weblogic.i.b.i(Unknown Source)
    I am running the exect code in a non-debug enviroment and it works
    fine. Does anybody know what the problem could be?
    Thanks,
    Branka Billante
    Moai Technologies, Inc.--
    Chuck Karish BEA Systems
    [email protected] San Francisco, CA
    (415) 317-0182 (cell) (415) 402-7692

  • Parse XML document ,create table according to tags &  load data to  table

    Hi All!
    I have one of the most common problem, one faces when dealing with xml stuff and oracle.I get xml documents, with each file having different tags.I want to write a pl/sql procedure such that, the xml file is parsed, a table is created with the tag names becoming the column names and all the nodes' data get inserted into the table as rows.I am using oracle 10g.
    I read a thread at the following url:
    Parse XML and load into table
    But did not get much of it.
    Can anybody please tell me how to accomplish this.
    Thanking in advance.
    Regards,
    Deepika.

    Why do people have such an aversion to the XML DB forum for XML questions...
    See FAQ for XML DB forum here: XML DB FAQ
    Explains all about getting XML into tables in the database.

Maybe you are looking for

  • Using iMac 2011 to display a PC

    Dose anyone using iMac 2011 to display a PC by Mini displayport to VGA(or DVI) cable! I used a Mini displayport to VGA cable and press commead+F2 button, but it was nothing happen. that is the cable I've used. http://store.apple.com/us/product/MB572Z

  • Unable to start cs3 server on os x 10.6.3

    After starting from a shell server terminates with following error: Sun Jun  6 12:28:11 2010 INFO    [Server] Initialisierung Sun Jun  6 12:28:11 2010 INFO    [Server] Anwendung wird geladen Sun Jun  6 12:28:11 2010 INFO    [Server] Zusatzmodule werd

  • Manipulating JDBC Datasources from a java application or servlet

    How can i manipulate - add, delete, update - JDBC Datasources from a java applcation or servlet?

  • Trouble with my dropdown menu

    I'm new to Java and I am getting pretty frustrated. I need a drop-down menu in my calculator and I'm probably doing this all wrong. When I compile my code, I don't get any errors but when I run it, I get: Exception in thread "AWT-EventQueue-0" java.l

  • Single button for line and SD on cisco 7861 SIP phone

    Hi All, Good evening. Can we configure one button for DN(Line) and SD. Our requirement is we need to configure one button for incoming and SD to a particular number. Thanks in Advance. Regards Sankar.