Issue with parsing an xml document and namespaces

I am having an issue when parsing an xml document that includes a namespace.
Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<StatusFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" TxCnt="247" TxTotal="5756845.31" SourceId="3" xmlns="http://www.test.com/cig/payments/optimizer/status/2004/10/">
<Tx PmtId="350031" Amt="16739" TxSts="09" CustSts="04" ChkNum="10605770" />
<Tx PmtId="350990" Amt="31698.66" TxSts="09" CustSts="04" ChkNum="10605821" />
<Tx PmtId="354992" Amt="201320.08" TxSts="09" CustSts="04" />
<Tx PmtId="349277" Amt="6675.17" TxSts="09" CustSts="04" ChkNum="10605822" />
<Tx PmtId="354979" Amt="66949.75" TxSts="09" CustSts="04" ChkNum="10605823" />
<Tx PmtId="349341" Amt="63258.49" TxSts="09" CustSts="04" ChkNum="10605824" />
<Tx PmtId="350025" Amt="5866.04" TxSts="09" CustSts="04" ChkNum="10605830" />
<Tx PmtId="350024" Amt="15671.8" TxSts="09" CustSts="04" ChkNum="10605831" />
<Tx PmtId="346822" Amt="9880.64" TxSts="09" CustSts="04" />
<Tx PmtId="350023" Amt="1360" TxSts="09" CustSts="04" />
<Tx PmtId="349802" Amt="131267" TxSts="09" CustSts="04" ChkNum="10605832" />
<Tx PmtId="343573" Amt="14532.76" TxSts="09" CustSts="04" ChkNum="10605833" />
<Tx PmtId="352675" Amt="4436" TxSts="09" CustSts="04" />
<Tx PmtId="350022" Amt="1260" TxSts="09" CustSts="04" ChkNum="10605834" />
<Tx PmtId="349714" Amt="80778" TxSts="09" CustSts="04" ChkNum="10605835" />
<Tx PmtId="352676" Amt="10136" TxSts="09" CustSts="04" ChkNum="10605836" />
<Tx PmtId="352679" Amt="25511.69" TxSts="09" CustSts="04" ChkNum="10605837" />
<Tx PmtId="346502" Amt="12842.69" TxSts="10" CustSts="05" />
<Tx PmtId="346503" Amt="4232.61" TxSts="09" CustSts="04" ChkNum="10605838" />
</StatusFile>
Here is my current code base:
CREATE OR REPLACE PROCEDURE ParseXML(xml VARCHAR2) IS
myParser xmlparser.parser := xmlparser.newparser;
myDoc xmldom.DOMNode;
myNodes xmldom.DOMNodeList;
myElement xmldom.DOMElement;
trec NDE_CIG_STATUS_TRANSACTIONS%ROWTYPE;
BEGIN
xmlparser.parseBuffer(myParser,xml);
myDoc := xmldom.makeNode(xmlparser.getDocument(myParser));
myNodes := xslprocessor.selectNodes(myDoc,'//Tx');
FOR i IN 0..xmldom.getLength(myNodes)-1 LOOP
myElement := xmldom.makeElement(xmldom.item(buyOrders,i));
trec.pmt_id := xmldom.getAttribute(curBuy,'PmtId');
INSERT INTO NDE_CIG_STATUS_TRANSACTIONS(PMT_ID) VALUES (trec.pmt_id);
END LOOP;
COMMIT;
END ParseXML;
If I remove the namespace, everything works just fine. The issue is that I cannot remove the namespace.
Anyone have any suggestions on how I can get the xslprocessor.selectNodes to recognize my namespace?
Thanks,
Mark Moran

Everyone,
Well after lots of hours spent reading web pages and blogs, etc... I was able to re-write my procedure and get it to work with different calls.
Here is my updated code.
PROCEDURE PARSE_STATUS_XML(P_FILE_NAME IN VARCHAR2, P_XML_FILE IN CLOB) IS
V_PARSER XMLPARSER.PARSER := XMLPARSER.NEWPARSER;
V_DOCUMENT XMLDOM.DOMDOCUMENT;
V_NODES XMLDOM.DOMNODELIST;
V_ELEMENT XMLDOM.DOMELEMENT;
V_TBL_RECORD NDE_CIG_STATUS_TRANSACTIONS%ROWTYPE;
BEGIN
XMLPARSER.PARSECLOB(V_PARSER, P_XML_FILE);
V_DOCUMENT := XMLPARSER.GETDOCUMENT(V_PARSER);
V_ELEMENT := XMLDOM.GETDOCUMENTELEMENT(V_DOCUMENT);
V_NODES := XMLDOM.GETELEMENTSBYTAGNAME(V_ELEMENT,'Tx','http://www.test.com/cig/payments/optimizer/status/2004/10/');
FOR I IN 0..XMLDOM.GETLENGTH(V_NODES)-1 LOOP
V_ELEMENT := XMLDOM.MAKEELEMENT(XMLDOM.ITEM(V_NODES,I));
V_TBL_RECORD.PMT_ID := XMLDOM.GETATTRIBUTE(V_ELEMENT,'PmtId');
V_TBL_RECORD.PMT_AMT := XMLDOM.GETATTRIBUTE(V_ELEMENT,'Amt');
V_TBL_RECORD.E_STATUS_CODE := XMLDOM.GETATTRIBUTE(V_ELEMENT,'TxSts');
V_TBL_RECORD.E_REASON_CODE := XMLDOM.GETATTRIBUTE(V_ELEMENT,'StsRsn');
V_TBL_RECORD.E_CUSTOMER_STATUS_CODE := XMLDOM.GETATTRIBUTE(V_ELEMENT,'CustSts');
V_TBL_RECORD.UPS_TRACKING_NBR := XMLDOM.GETATTRIBUTE(V_ELEMENT,'UpsTrcNum');
V_TBL_RECORD.FED_REFERENCE_NBR := XMLDOM.GETATTRIBUTE(V_ELEMENT,'FedRefNum');
V_TBL_RECORD.FIDB_TRACKING_NBR := XMLDOM.GETATTRIBUTE(V_ELEMENT,'FIDbtTrcNum');
V_TBL_RECORD.CHECK_NBR := XMLDOM.GETATTRIBUTE(V_ELEMENT,'ChkNum');
INSERT INTO NDE_CIG_STATUS_TRANSACTIONS(
CREATE_DATE,
XML_FILE_NAME,     
PMT_ID,
PMT_AMT,
E_STATUS_CODE,
E_REASON_CODE,
E_CUSTOMER_STATUS_CODE,
UPS_TRACKING_NBR,
FED_REFERENCE_NBR,
FIDB_TRACKING_NBR,
CHECK_NBR
     VALUES (
SYSDATE,
P_FILE_NAME,
V_TBL_RECORD.PMT_ID,
V_TBL_RECORD.PMT_AMT,
V_TBL_RECORD.E_STATUS_CODE,
V_TBL_RECORD.E_REASON_CODE,
V_TBL_RECORD.E_CUSTOMER_STATUS_CODE,
V_TBL_RECORD.UPS_TRACKING_NBR,
V_TBL_RECORD.FED_REFERENCE_NBR,
V_TBL_RECORD.FIDB_TRACKING_NBR,
V_TBL_RECORD.CHECK_NBR
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
     RAISE;
END PARSE_STATUS_XML;
Mark

Similar Messages

  • Parsing an xml document inside a Thread

    Hi Friends
    I have to do some processing in my application for which i need to use multithreading.
    Inside every new thread created i have to parse an xml document using s parsing tool like castor or jibx.
    My question is that is it possible to parse a xml document inside a new thread everytime it gets created.
    is it a good coding practice as it involves java code to do it.
    Thanks
    Vikeng

    vikeng wrote:
    Hi
    Thanks for the reply.
    Well i need to do some kind of a batch processing in my application.
    I need to parse an xml document and upload the data i get after parsing into columns in the database.
    Since its a batch what i was asking was is it possible to do it for every request as batch needs to handle hundreds of records during the daily or nightly sync.
    Is it a good practice to do parsing for every record in a batch
    Thanks
    VikengI don't get it. One batch is one document, and that document contains e.g. 100 records? What's one request? A request for one batch? I would execute one batch in one thread.
    Kaj

  • Poweshell script to parse a XML document to get all Leaf level nodes with Node names in CSV

    Hi Experts,
    I want to write a Powershell script to parse a XML document to get all Leaf level nodes with Node names in CSV
    <?xml version="1.0" encoding="UTF-8"?>
    <CATALOG>
       <CD>
          <TITLE>Empire Burlesque</TITLE>
          <ARTIST>Bob Dylan</ARTIST>
          <COUNTRY>USA</COUNTRY>
          <COMPANY>Columbia</COMPANY>
          <PRICE>10.90</PRICE>
          <YEAR>1985</YEAR>
       </CD>
    </CATALOG>
    Need to display this as
    CD_Tiltle, CD_ARTIST, CD_COUNTRY, CD_COMPANY, CD_PRICE, CD_YEAR
    Empire Burlesque, Bob Dylan,USA,Columbia,10.90,1985
    and so on..
    I do not want to hard code the tag names in the script.
    current example is 2 level hierarchy XML can be many level till 10 max I assume
    in that case the csv file field name will be like P1_P2_P3_NodeName as so on..
    Thanks in advance
    Prajesh

    Thankfully, I have writtenscript for ths same $node_name="";
    $node_value="";
    $reader = [system.Xml.XmlReader]::Create($xmlfile)
    while ($reader.Read())
    while ($reader.Read())
    if ($reader.IsStartElement())
    $node_name += "," + $reader.Name.ToString();
    if ($reader.Read())
    $node_value += "," + $reader.Value.Trim();
    Thanks and Regards, Prajesh Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

  • JSP documents and namespaces

    I have an issue involving JSP documents (i.e. JSP pages that are
              well-formed XML documents). I am using namespaces on children elements
              of the <jsp:root> element, because my JSP page generates XML with
              namespaces. The simple fragment below illustrates this:
              <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
              version="1.2">
              <d:document xmlns:d="http://example.org/xml/document">
              <d:head>
              <d:title>Example</d:title>
              </d:head>
              <d:body>
              Some Text.
              </d:body>
              </d:document>
              </jsp:root>
              This example works with Tomcat 4 and Tomcat 5, but fails with WL
              8.1. I get an error like this:
              /example/my.jsp(20): no corresponding open tag for tag extension
              close: //[ ; Line: 20]
              probably occurred due to an error in /example/my.jsp line 20:
              </d:document>
              This seems to be a bug in the WebLogic JSP implementation. It should
              be possible to generate XML documents containing namespaces. The JSP
              1.2 spec is actually silent on this, but it says (JSP.5.2.2):
              "the root is where namespace attributes of taglibs will be inserted.
              All tag libraries used within the JSP document are represented in the
              root element through additional xmlns attributes."
              This to me implies that namespace declarations occurring elsewhere in
              the document are not interpreted as tag libs and therefore should be
              handled like regular tags.
              Any help is appreciated.
              -Erik
              

              "Erik Bruchez" <[email protected]> wrote in message
              news:[email protected]...
              > Thanks Nagesh,
              >
              > In passing, looking at the latest JSP 2.0 spec, I found out that there
              > may be an additional issue in the future, as the 2.0 spec allows for
              > tag libraries namespace declarations everywhere in the document. How
              > are you going to be able to generate XML documents with namespaces if
              > every namespace is necessarily bound to a tag library? The spec does
              > not seem to address this at all. I have emailed my feedback to the
              > JSR, but it would be interesting to have the opinion of WebLogic
              > developers on this.
              >
              > -Erik
              As far as i can remember, this doesn't restrict the namespaces in themselves
              i.e not attached to any taglibs. Given a namespace which is not resolved as
              a taglib, it will be considered a standard namespace no? .. Am i missing
              something. Also which section and which PFD version of the spec are you
              looking at? It would be great if you can give a little more detail about the
              issue so it can be fixed in the spec if possible..
              I would also be interested in knowing how you are using the Jsp documents
              (in xml format) in general. (since I'm trying to get an insight into the
              various ways in which jsp Docs are being used by customers)
              Nagesh
              >
              > Nagesh Susarla <[email protected]> wrote in message
              news:<[email protected]>...
              > > Hi Erik,
              > >
              > > Indeed this does look like a bug in the wls jsp container. Attributes
              > > with ':' in them are not being lexed correctly. I've opened CR111972 to
              > > track this issue, so please contact [email protected] for necessary
              patches.
              > >
              > > thanks
              > > Nagesh
              > >
              > > Erik Bruchez wrote:
              > > > I have an issue involving JSP documents (i.e. JSP pages that are
              > > > well-formed XML documents). I am using namespaces on children elements
              > > > of the <jsp:root> element, because my JSP page generates XML with
              > > > namespaces. The simple fragment below illustrates this:
              > > >
              > > > <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
              > > > version="1.2">
              > > > <d:document xmlns:d="http://example.org/xml/document">
              > > > <d:head>
              > > > <d:title>Example</d:title>
              > > > </d:head>
              > > > <d:body>
              > > > Some Text.
              > > > </d:body>
              > > > </d:document>
              > > > </jsp:root>
              > > >
              > > > This example works with Tomcat 4 and Tomcat 5, but fails with WL
              > > > 8.1. I get an error like this:
              > > >
              > > > /example/my.jsp(20): no corresponding open tag for tag extension
              > > > close: //[ ; Line: 20]
              > > > probably occurred due to an error in /example/my.jsp line 20:
              > > > </d:document>
              > > >
              > > > This seems to be a bug in the WebLogic JSP implementation. It should
              > > > be possible to generate XML documents containing namespaces. The JSP
              > > > 1.2 spec is actually silent on this, but it says (JSP.5.2.2):
              > > >
              > > > "the root is where namespace attributes of taglibs will be inserted.
              > > > All tag libraries used within the JSP document are represented in the
              > > > root element through additional xmlns attributes."
              > > >
              > > > This to me implies that namespace declarations occurring elsewhere in
              > > > the document are not interpreted as tag libs and therefore should be
              > > > handled like regular tags.
              > > >
              > > > Any help is appreciated.
              > > >
              > > > -Erik
              

  • Problem with encoding of xml document

    while parsing an xml document with SAX parser, i found that encoding of the xml document received as input stream is "ISO-8859-1" . After parsing certain fields has to be stored in the mysql table where table character set is "utf8" . Now what i found that ceratin characters in the original XML document are stored as question mark (?) in the database.
    1. I am using mysql 4.1.7 with system variable character_set_database as "utf8". So all my tables have charset as "utf8".
    2. I am parsing some xml file as inputsream using SAX parser api (org.apache.xerces.parsers.SAXParser ) with encoding "iso-8859-1". After parsing certain fields have to be stored in mysql database.
    3. Some XML files contain a "iso-8859-1" character with character code 146 which appears like apostrophes but actually it is : - � and the problem is that words like can�t are shown as can?t by database.
    4. I notiicied that parsing is going on well and character code is 146 while parsing. But when i reterive it from the database using jdbc it shows character code as 63.
    5. I am using jdbc to prepared statement to insert parsed xml in the database. It seems that while inserting some problem occurs what is this i don't know.
    6. I tried to convert iso-8859-1 to utf-8 before storing into database, by using
    utfString = new String(isoString.getBytes("ISO-8859-1"),"UTF-8");
    But still when i retreive it from the databse it shows caharcter code as 63.
    7. I also tried to retrieve it using , description = new String(rs.getBytes(1),"UTF-8");
    But it also shows that description contains character with code 63 instead of 146 and it is also showing can�t as can?t
    help me out where is the problem in parsing or while storing and retreiving from database. Sorry for any spelling mistakes if any.

    duggal.ashish wrote:
    3. Some XML files contain a "iso-8859-1" character with character code 146 which appears like apostrophes but actually it is : - &#146; and the problem is that words like can&#146;t are shown as can?t by database.http://en.wikipedia.org/wiki/ISO8859-1
    Scroll down in that page and you'll see that the character code 146 -- which would be 92 in hexadecimal -- is in the "unused" area of ISO8859-1. I don't know where you got the idea that it represents some kind of apostrophe-like character but it doesn't.
    Edit: Actually, I do know where you got that idea. You got it from Windows-1252:
    http://en.wikipedia.org/wiki/Windows-1252
    Not the same charset at all.

  • Convert flat file to XML document and store into Oracle database

    First:
    I have a flatfile and created external table to read that file in Oracle
    Now I want to create an XML document for each row and insert into Oracle database, I think that XMLtype.
    Could you please provide me some information/steps.
    Second:
    Is there performance issues, because everyday I need to check that XML document stored in the database against the in coming file.
    Thank You.

    Oracle 11g R2 Sun Solaris
    Flat file is | (pipe delimited), so I did create an EXTERNAL Table
    row1     a|1|2|3|4
    row2     b|2|3|4|5
    row3     c|6|7|8|9
    I want to store each record as XML document. So it will be easy to compare with next day's load and make insert or update.
    The reason is:
         First day the file comes with 5 columns
         after some days, the file may carry on some additional columns more than 5
         In this case I do not want to alter table to capture those values, if I use XML than I can capture any number of columns, CORRECT!. Please make me correct If I am wrong.
         This is the only reason to try to use the XMLType (XML Document)
         On Everyday load we will be matching these XML documents and update it if there is any column's value changes
    daily average load will be 10 millions and initial setup will be 60-80 millions
         Do I have anyother option to capture the new values without altering the table.
    Please advise!.

  • Parsing String XML Document

    I didn't find a method that parses a XML document when it's not a file. I have a String that I want to parse and the method DocumentBuilder.parse only accepts a String that is a uri to a file.
    I write this code:
    String strXML = "<?xml version='1.0' ?><root><node>anything</node></root>";
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    domDoc = docBuilder.parse(strXML);
    Please gimme a light!!
    []'s
    Saulo

    I have a similar problem, I'm trying to do the same BUT in a servlet, it compiles and it actually works if I use it outside my servlet, but, when I mount the servlet with the code similar to this one here it doesn't read the string (at least that's what appears to be, because it doesn't writes to my DB as it should and it doesn't display anything as I'm specifying as my servlet response). Any help? I'm posting my code here:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.BufferedReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.w3c.dom.*;
    import org.apache.xml.serialize.*;
    import java.net.URLDecoder;
    import java.sql.*;
    import org.xml.sax.InputSource;
    import java.io.StringReader;
    public class SMSConnector extends HttpServlet
    //Public variables we will need
    public String Stringid;
    public String Stringpath;
    public String st;
    public int nid;
    //Servlet service method, which permits listening of events
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    //Initialization for the servlet
    ServletOutputStream salida = res.getOutputStream();
    ServletInputStream entrada = req.getInputStream();
    //Reading of the entering string
    BufferedReader lector = new BufferedReader(new InputStreamReader (entrada));
    res.setContentType("text/HTML");
    try {
    //Database handler
    Class.forName("org.gjt.mm.mysql.Driver");
    //DocumentBuilderFactory factory =
    //DocumentBuilderFactory.newInstance();
    //DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource inStream = new InputSource();
    inStream.setCharacterStream(new StringReader(lector.readLine()));
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document doc1 = docBuilder.parse(inStream);
    NodeList listasms = doc1.getElementsByTagName("sms");
    for(int s=0; s<listasms.getLength() ; s++)
    Connection Conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/smsdb","root", "");
    Node nodosms = listasms.item(s);
    if(nodosms.getNodeType() == Node.ELEMENT_NODE){
    Element elementosms = (Element)nodosms;
    NodeList listatelf = elementosms.getElementsByTagName("tlf");
    Element elementotelf = (Element)listatelf.item(0);
    NodeList textTelfList = elementotelf.getChildNodes();
    String telefono = ((Node)textTelfList.item(0)).getNodeValue();
    //String SendingAddress = ((Node)textAddressList.item(0)).getNodeValue().trim();
    salida.println(telefono);
    NodeList listaop = elementosms.getElementsByTagName("op");
    Element elementoop = (Element)listaop.item(0);
    NodeList textOpList = elementoop.getChildNodes();
    String operadora = ((Node)textOpList.item(0)).getNodeValue();
    NodeList listasc = elementosms.getElementsByTagName("sc");
    Element elementosc = (Element)listasc.item(0);
    NodeList textSCList = elementosc.getChildNodes();
    String shortcode = ((Node)textSCList.item(0)).getNodeValue();
    NodeList listabody = elementosms.getElementsByTagName("body");
    Element elementobody = (Element)listabody.item(0);
    NodeList textBodyList = elementobody.getChildNodes();
    String body = ((Node)textBodyList.item(0)).getNodeValue();
    Statement sta = Conn.createStatement();
    sta.executeUpdate("INSERT INTO smstable (telf,op,sc,body) VALUES ('" + telefono + "','" + operadora + "','" + shortcode + "','" + body + "')");
    Conn.commit();
    Conn.close(); }
    //Catching errors for the SAX and XML parsing
    catch (SAXParseException err)
    System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
    System.out.println(" " + err.getMessage ());
    catch (SAXException e)
    Exception x = e.getException ();
    ((x == null) ? e : x).printStackTrace ();
    catch (Throwable t)
    t.printStackTrace ();
    }

  • My Task is To Parse a XML Document to Return CLOB's

    Hi folks
    I am writing this mail in the hope of getting a help.Please
    give me a shoulder to keep me going.
    The task is to parse a XML document for a specific Tag and
    read the Tag content in CLOB to return CLOB.
    I know that the writetoclob will do the job as
    per oracle documentation.
    I am giving the code where i got stuck.
    Please help me complete my rest of coding.
    Thanks
    Input variables are
    XMLin in CLOB, -- Incoming XML Document Structure
    Partype in varchar2, -- Tagname
    Result out CLOB -- Return Tag value CLOB data type.
    My Code : -
    Declare
    p xmlparser.parser;
    d xmldom.DOMDocument;
    e xmldom.DOMElement;
    nl xmldom.DOMNodeList;
    n xmldom.DOMNode;
    tagvalue varchar2(255);
    paramsIn Clob;
    result CLOB;
    BEGIN
    --loading SecXML
    dbms_lob.createtemporary(paramsIn,true);
    dbms_lob.append(paramsIn,XMLin);
    --dbms_output.put_line('ParsebyTag ='||Partype);     
    --defining parser
    p := xmlparser.newparser;
    xmlparser.parseClob(p,paramsIn);
    d := xmlparser.getDocument(p);
    --get tagvalue
    nl := xmldom.getElementsByTagName(d,partype);
    n := xmldom.item(nl,0);
    IF xmldom.getlength (nl) > 0
    THEN
    n := xmldom.item (nl, 0);
    =>=>=> => xmldom.writetoclob (n, result); <=<=<=<=<=<=====
    END IF;
    return; -- from a procedure
    The above line marked with a arrow does not work for CLOB Variables.
    Please explain with a corrected code to complete this task.
    Thanks for reading my request.
    Please reply to this message poster as i am frequently
    checking this to see a answer.
    my email is [email protected]
    Balaji.

    First, you have 2 variables with the same name,
    Second, let me show you what is that you need to do:
    PROCEDURE WriteDataToClob(XMLin in CLOB, Partype in varchar2, Result out CLOB) IS
    Declare
    p xmlparser.parser;
    d xmldom.DOMDocument;
    e xmldom.DOMElement;
    nl xmldom.DOMNodeList;
    n xmldom.DOMNode;
    tagvalue varchar2(255);
    TempClob Clob;
    BEGIN
    --Create a temporary clob
    dbms_lob.createtemporary(TempClob,true);
    --loading SecXML
    --defining parser
    p := xmlparser.newparser;
    xmlparser.parseClob(p,XMLin);
    d := xmlparser.getDocument(p);
    --get tagvalue
    nl := xmldom.getElementsByTagName(d,partype);
    n := xmldom.item(nl,0);
    IF xmldom.getlength (nl) > 0 THEN
    n := xmldom.item (nl, 0);
    xmldom.writetoclob (n, TempClob );
    END IF;
    Result := TempClob;
    dbms_lob.FreeTemporary(TempClob);
    END;

  • How do I parse a XML document?

    Hello
    I have a problem parsing a XML-document like the one below: Can anyone help me with a code example or something to get the tag "<Name>" out so that I get the string "Example5" and "Example3" out.
    Thnx for any help!
    Jimmy
    The XML file looks like this (but without the line in the beginning of each row):
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) -->
    <!DOCTYPE ThisExample SYSTEM "C:/example.dtd">
    <?xml-stylesheet type="text/xsl" href="first.xslt"?>
    <ThisExample>
    ____<Product>
    ________<Product_number>no1</Product_number>
    ________<Number>number1</Number>
    ____</Product>
    ____<Product>
    ________<Product_number>no2</Product_number>
    ________<Number>number2</Number>
    ____</Product>
    ____<Group>
    ________<Type>EX1</Type>
    ________<ProductVersionAllowed>Y</ProductVersionAllowed>
    ________<Preprocess>precmd.csh</Preprocess>
    ________<Postprocess>echo Finished</Postprocess>
    ________<Document>
    ____________<Name>Example1</Name>
    ____________<Product_number>no1</Product_number>
    ____________<Ticked_by_default>Y</Ticked_by_default>
    ________</Document>
    ________<Document>
    ____________<Name>Example2</Name>
    ____________<Product_number>no1</Product_number>
    ____________<Ticked_by_default>Y</Ticked_by_default>
    ________</Document>
    ________<Document>
    ____________<Name>Example3</Name>
    ____________<Product_number>no1</Product_number>
    ____________<Ticked_by_default>Y</Ticked_by_default>
    ________</Document>
    ____</Group>
    ____<Group>
    ________<Type>EX2</Type>
    ________<ProductVersionAllowed>N</ProductVersionAllowed>
    ________<Preprocess>precmd.csh</Preprocess>
    ________<Postprocess>echo Finished</Postprocess>
    ________<Document>
    ____________<Name>Example4</Name>
    ____________<Product_number>no2</Product_number>
    ____________<Ticked_by_default>Y</Ticked_by_default>
    ________</Document>
    ________<Document>
    ____________<Name>Example5</Name>
    ____________<Product_number>no2</Product_number>
    ____________<Ticked_by_default>Y</Ticked_by_default>
    ________</Document>
    ____</Group>
    </ThisExample>

    Thnx :O)
    Now it worx!
    Just one more thing. Can I get the number of elements there is in a tag? I.e. how many "Document"'s there are in 1 "Group"? I need this because I have too loop through a "Group" and print the name of every "Document".
    At the moment I'm doing it like below, but that is not a nice solution, and it realy does not work that well:
    Jimmy
    int i = 1;
    do
    node = org.apache.xpath.XPathAPI.selectSingleNode(doc, "/PosttoolControl/Group[position()=" + i + "]/Type");
    if (node.getFirstChild().getNodeValue() != null)
    type = node.getFirstChild().getNodeValue();
    PostToolDocGroupeComboBox.addItem(type);
    i++;
    } while (node.getFirstChild().getNodeValue() != null);

  • Unable to display tree view; Error when parsing an XML document (Premature end of file.)

    Hi folks,
    I am using a cascaded mapping in my OM. I have a graphical mapping followed by the Java mapping. It is a flat file to IDOC mapping. Everything works fine in Dev but when I transport the same objects to QA, the Operation mapping though it doesn't fail in ESR testing tool, gives the following message and there is no output generated for the same payload which is successfully tested in DEV. Please advise on what could be the possible reasons.
    Unable to display tree view; Error when parsing an XML document (Premature end of file.)

    kalyan,
    There seems to be an invalid xml payload which causes this error in ESR not generating the tree view. Please find the similar error screenshot and rectify the payload.
    Mutti

  • Goods Issue with reference to Material document

    Hello,
    I would like to create Goods Issue with reference to material document (Transfer Posting document) , but the following message appears :
    "Selected material document does not correspond with action to be executed".
    Is it possible to create Goods Issue with reference to Transfer Posting (mov.type 311 - from stor.loc. to stor.loc.)  ?
    Thanks

    Thanks,
    probably I'll have to find another way to solve this business requirement of copying the transfer document data in GI.
    We have an auto created transfer postings via interface from another system and the main idea was to use already entered fields in transfer posting document such as material , quantity , text , goods recepient , etc. and not to enter them twice when GI should be created. In our case (it's a case for certain materials) it's always 1:1 relationship, so the idea was to facilitate the job of creating the GI, because GI should contain the same data as in transfer posting document.

  • How to parse multiple xml documents from single buffer

    Hello,
    I am trying to use jaxb 2.0 to parse a buffer which contains multiple xml documents. However, it seems that it is meant to only parse a single document at a time and throws an exception when it gets to the 2nd document.
    Is there a way I can tell jaxb to only parse the first complete document and not fetch the next one out of the buffer? Or what is the most efficient way to separate the buffer into two documents without parsing it manually. If I have to search the buffer for the next document root and then split the buffer, it seems like that defeats the purpose of using jaxb as the parser.
    I am using the Unmarshaller.unmarshall method and the exception I am getting is:
    org.xml.sax.SAXParseException: Illegal character at end of document, &#x3c;.]
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:476)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:198)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:167)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184)
    Thank you for your help

    It's just like any other XML parser, it's only designed to parse one XML document. If you have something that concatenates two XML documents together (that's what your "buffer" sounds like), then stop doing that.

  • Parseing an XML Document as a String

    Hi all,
    i am trying to parse an XML document to a parser. I get the file as a request parameter, which is filled in to at String variable.
    But for some reason i get an SAXException, does anyone se the problem?
    Thank you for your help...
    Below is the code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.text.*;
    import java.net.*;
    import java.net.URL;
    import java.sql.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import javax.xml.parsers.*;
    import javax.xml.transform.stream.StreamSource;
    public class StartServlet extends HttpServlet
    private boolean debug = true;
    private final static String CONTENT = "content";
    private final static String COOKIES = "cookies";
    String resp = new String();
    private static String NODE_TYPES[] = new String[] {
         "ELEMENT",
         "ATTRIBUTE",
         "TEXT",
         "CDATA_SECTION",
         "ENTITY_REFERENCE",
         "ENTITY",
         "PROCESSING_INSTRUCTION",
         "COMMENT",
         "DOCUMENT",
         "DOCUMENT_TYPE",
         "DOCUMENT_FRAGMENT",
         "NOTATION" };
    public static void println(String s, int indent) {
         for(int i = 0 ; i < indent; i++) {
                   System.out.println(" ");
         System.out.println(s);
    public static void println(String s) {
         System.out.println(s);
    public static void print(Node node){
         printImpl(node, 0);
    public static void printImpl(Node node, int indent){
         if(node == null) {
              return;
         String nodeType = NODE_TYPES[node.getNodeType()];
         String nodeName = node.getNodeName();
         String nodeValue = node.getNodeValue();
         if(nodeValue != null) {
              nodeValue = nodeValue.trim();
         if(nodeType.equals("TEXT") && nodeValue.equals("")) {
              ; //Ignore emty node
         else {
              println(nodeType + " - " + nodeName + " - " + nodeValue, indent);
         NamedNodeMap attributes = node.getAttributes();
         if (attributes != null) {
              for(int i = 0; i < attributes.getLength(); i++) {
                   printImpl(attributes.item(i), indent + 1);
         NodeList children = node.getChildNodes();
         if(children != null) {
              for(int i = 0; i < children.getLength(); i++){
                   printImpl(children.item(i), indent + 1);
    public static DocumentBuilder newBuilder(boolean validation)
                        throws ParserConfigurationException {
         DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
         domFactory.setValidating(validation);
         domFactory.setNamespaceAware(true);
         DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
         //domBuilder.setErrorHandler(new PrintErrorHandler());
         return domBuilder;
    public static Document newDocument()
                        throws ParserConfigurationException{
         DocumentBuilder domBuilder = newBuilder(false);
         Document document = domBuilder.newDocument();
         return document;
    public static Document parse( String xml, boolean validation)
                        throws ParserConfigurationException, IOException, SAXException {
              DocumentBuilder domBuilder = newBuilder(validation);
              Document document = domBuilder.parse(xml);
              return document;
    public void init() {
    public void service( javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) {
              String[] cookies = null;
              try{
                   Hashtable document = getDocument("http://.../first.xml", cookies);
                   resp = (String) document.get(CONTENT);
                   debug(resp);
                   print(parse(resp, false));
              catch (SAXParseException e){
                   System.out.println("Saxfejl");
                   //System.exit(1);
              catch (Exception e){
                   e.printStackTrace();
                   System.exit(1);
    public void debug(String msg) {
         if(debug) {
              System.out.println(msg);
    public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
         try
              // Insert user code from here.
         catch(Throwable theException)
              // uncomment the following line when unexpected exceptions
              // are occuring to aid in debugging the problem.
              //theException.printStackTrace();
    public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
         performTask(request, response);
    public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
         performTask(request, response);
    private Hashtable getDocument(String urlCode, String[] oldCookies) {
         Hashtable document = new Hashtable();
         HttpURLConnection http = null;
         try {
              URL httpURL = new URL(urlCode);
              // If HTTP Protocol, then open connection using the Request method indicated
              URLConnection conn = httpURL.openConnection();
              http = (HttpURLConnection) conn;
              //http.setRequestMethod("GET");
              http.setDoInput(true);
              http.setDoOutput(true);
              http.setUseCaches(false);
              http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
              if (oldCookies != null) {
                   for (int j = 0; j < oldCookies.length; j++) {
                        String cookie = oldCookies[j];
                        http.setRequestProperty("Cookie", cookie);
              http.connect();
              http.getContent();
              StringBuffer tsb = new StringBuffer("");
              if (http.getResponseCode() == 200) {
                   InputStream cis = http.getInputStream();
                   byte[] a = new byte[1024];
                   int n = cis.read(a);
                   while (n >= 0) {
                        tsb.append(new String(a, 0, n));
                        n = cis.read(a);
                   cis.close();
                   document.put(CONTENT, tsb.toString());
              String[] cookies = null;
              if (cookies == null) {
                   int headerFieldIndex = 0;
                   String headerFieldValue = http.getHeaderField(headerFieldIndex);
                   Vector cookieValues = new Vector();
                   while (headerFieldValue != null) {
                        String headerFieldName = http.getHeaderFieldKey(headerFieldIndex);
                        if ((headerFieldName != null) && headerFieldName.toLowerCase().equals("set-cookie")) {
                             int index = headerFieldValue.indexOf(";");
                             if (index > -1) {
                                  headerFieldValue = headerFieldValue.substring(0, index);
                             cookieValues.addElement(headerFieldValue);
                        headerFieldValue = http.getHeaderField(++headerFieldIndex);
                   cookies = new String[cookieValues.size()];
                   cookieValues.copyInto(cookies);
              document.put(COOKIES, cookies);
         catch (Exception e) {
              debug("url problem" + e);
         finally {
              if (http != null) {
                   http.disconnect();
         return document;
    }

    Hi,
    Use this code it will helpful to you.
    resultXMLDocument=(XmlDocument)documentDoc;
    StringWriter sw = new StringWriter();
    resultXMLDocument.write((Writer) sw);
    xmlString=sw.toString();
    thnaks,
    suneel

  • OSX 10.9.1 Compatibility issue with Sharp Aquos PN-L702B and PN-L802B

    I have Mac Mini's connected to the Sharp Aquos PN-L702B and PN-L802B touch screens and after updating to 10.9.1 am experiencing what appears to be a compatibility issue with the Sharp TPM driver and the OSX 10.9.1.  
    Everything works perfectly previously on 10.8.4 and 10.8.5.  I did not test on 10.9.0 as I went straight to 10.9.1.  Anyone else having this problem?  Any thoughts on resolution?

    OK so perserverance seems to have helped here - i used the cmd R function on start up to get to the page where i can re install OS X Lion - Safari now working.
    However i have Office 2011 for MAC and now Excel wont start so i will post on another thread for help with this
    Hope this helps if anyone has a similar issue

  • Issue with Acrobat 10.1.2 and Windows 7 64-bit Preview Handler

    Hi. I work in an enterprise environment that is currently migrating to  64-bit Windows 7. The only version of Acrobat we have approved for Windows 7 is 10.1.2. We're seeing an issue with this version that causes the preview handler to not work. The preview panel in Explorer is just white and will eventually give the error "Preview handler surrogate host has stopped working."  I've tried to fix listed on http://www.pretentiousname.com/adobe_pdf_x64_fix/index.html but that registry key is already correct. Our current work around for these users to just install Reader X1 and make it the default PDF handler, but I would like to find a better solution. Is there a known issue with Acrobat 10.1.2 and 64-bit operating systems? Or is there a way to change just the default preview handler?

    Most of the info on the web page you link to is 2-4 years old. I doubt it applies. Your workaround is actually the best solution: It's always preferred to use the latest PDF viewer. Reader and Acrobat can exist on the same machine.
    Also, why 10.1.2? There have been 6 releases since then with documented security enhancements (meaning there are also published vulnerabilities which are patched), bug fixesm, and feature enhancments.
    I'll ping some folks about the error you are getting. . .
    hth,
    Ben

Maybe you are looking for

  • Runtime Error in ALV Tree Output

    Dear All, I am trying to create a ALV Tree using Class cl_gui_alv_tree. The Report Shows the Output with the first Node but when i try to expand it is dumping with a runtime error GETWA_NOT_ASSIGNED in class CL_ALV_TREE_BASE and method SET_ITEMS_FOR_

  • In Fact Sheet, Open Leads View is displaying all Leads

    Hi Gurus, I have configured Account Fact Sheet(BP_Account_FS). I have added view "Open Leads", which should "display the last n leads that have status "open" or "in process". But In my case "Open Leads" is displaying all the Leads, which have status

  • How do i run java application on IIS

    Hi, Can I run java application on IIS(Internet information Server)? If yes, How do i do that? My java application contains JSP,Servlets and EJB. To run java application on IIS which plug in should i use. Can anybody help me This is urgent...........

  • Error message on Madonna - Confessions from a dance floor

    when i tried to open the link for the Madonna album Confessions On a Dance Floor (deluxe version) I received a message saying it wasn't going to be available until the year 2038. is there a way around this or is this simply a bug in the itunes system

  • Random Shutdown: Locked Clockspeed, Processor Voltage Correlation?

    I use Hardware Monitor to keep track of more sensor readouts than just temps. I recommend everyone install it. Using it, I've discovered some weird behavior in the processor clockspeed and voltage that correlates in a predictable with my typical macb