Regarding parsing XML

Hi ,
I am trying to Parse XML using XML DOM using jaxp1.1 parser.But till and untill my whole xml file does not appears in complete single line it does not give the required output(avoiding white spaces).
So when I am trying to use Instance(of documentBuilderFactory).setIgnoringElementContentWhitespace(true) I am getting a error that method not found in javax.xml.parsers;
Please Help me regarding this.

Try to use the Xerces parser from Apache instead.
You can download it from: http://xml.apache.org/
According to the XML standard spaces should be ignored by the parser.
Regards,
Jess

Similar Messages

  • Error parsing XML: {err}FORG0005: expected exactly one item, got 0 items

    Hi ,
    Good Morning to all
    in osb replace action am using xquery transformation resource.
    source code of xquery is :
    ====================================================================================
    (:: pragma bea:global-element-parameter parameter="$addition1" element="ns0:Addition" location="../wsdl/NewWSDLFile.wsdl" ::)
    (:: pragma bea:global-element-return element="ns1:process" location="../bpelprocess1_client_ep.wsdl" ::)
    declare namespace ns1 = "http://xmlns.oracle.com/POProcessing/AdditionOSB/BPELProcess1";
    declare namespace ns0 = "http://www.example.org/NewWSDLFile/";
    declare namespace xf = "http://tempuri.org/ServiceCallout/trans/route/";
    declare function xf:route($addition1 as element(ns0:Addition))
    as element(ns1:process) {
    <ns1:process>
    <ns1:value1>{ data($addition1/value1) }</ns1:value1>
    <ns1:value2>{ data($addition1/value2) }</ns1:value2>
    </ns1:process>
    declare variable $addition1 as element(ns0:Addition) external;
    xf:route($addition1)
    =====================================================
    at the time of running "error is Error parsing XML: {err}FORG0005: expected exactly one item, got 0 items " in replace action.
    how to resolve this problem...
    Thanks & Regards
    venky

    The reason for the error is the xquery is not able to find the values in the input... Check the input and namespaces...
    Try...
    <ns1:value1>{ data($addition1/ns0:value1) }</ns1:value1>
    <ns1:value2>{ data($addition1/ns0:value2) }</ns1:value2>Cheers,
    Vlad

  • Java stored proc performance parsing XML docs

    Hi
    We are using ORACLE 8i(8.1.6). I have a JAVA Stored procedure that parses XML doc and returns tha values. If I am testing on the box, I get an avg. return time of 2 secs. If I have 20 users, my return time for all went to 25 to 35 secs?
    Are there any parameters on ORACLE I can modify to increase the performance. We are developing app for 1000 to 1500 users. I dont want to guess the time based on my test with 20 users.
    Any help will be greatly appreciated.
    Thank You
    Raju

    Raju,
    Oracle 8.1.7 should be better choice for you since it does have the XML stuff
    natively compiled.
    Regarding scaleability the JVM should scale
    very well. However let us know what you find.
    - Stefan

  • Parsing XML from a session bean

    Hi,
    I am trying to use a Sax parser for parsing xml received from a back end
    legacy system. The code is executed from a Session bean.
    Debugging learned me that the parse() method on the parser hangs the
    container without any error or exception trace. The code works fine outside
    a container.
    All help will be highly appreciated.
    Kurt

    I found out that the InputStream implementation used parsing source inside
    the container is different
    then from the one outside (other type of VM of course!). The Weblogic
    implementation blocks at the end of
    the stream, while the normal SUN JDK 1.3 returns. This is not a bug, the bug
    I found is in my proxy that allows
    the connection to the backend. This proxy allows HTTP connections, and I
    parse the XML received over HTTP.
    Regards,
    Kurt
    "Todd Karakashian" <[email protected]> wrote in message
    news:[email protected]..
    That's seems odd. Perhaps there is something going on in your document
    handler code that triggers a hang in the environment of the server.
    When you see the hang, instruct the VM to give you a thread dump (type
    control-<break> on Windows, <control>-\ (backslash) on UNIX in the
    window in which the server is running; the results are dumped to
    stderr). That will show what every thread in the server is doing. If you
    email or post the thread dump, I will take a look at it and see if I can
    see what is going on. Also, let us know which platform, VM, parser, and
    WebLogic version you are using.
    Regards,
    -Todd
    Kurt Quirijnen wrote:
    Hi,
    I am trying to use a Sax parser for parsing xml received from a back end
    legacy system. The code is executed from a Session bean.
    Debugging learned me that the parse() method on the parser hangs the
    container without any error or exception trace. The code works fine
    outside
    a container.
    All help will be highly appreciated.
    Kurt--
    Todd Karakashian
    BEA Systems, Inc.
    [email protected]

  • Error in retrieving and parsing XML File

    Hi Folks
    I am Working on People centric user interface, While i am custimizing a application in Business application Builder i am getting this error
    " Error in retrieving and parsing XML File "
    can any body look on this and give me the solution
    it will be rewarded
    Regards
    M.S.Kumar

    Hello,
    As mentionned by SAP_TECH, avoid to use the BAB.
    Go to CRMC_BLUEPRINT_C and use the different option in the menu to customize the field group, toolbar group, events, ...
    Use the PCUI cookbook to find your way.
    Regards,
    Fred

  • Problem parsing xml in J2ME (using kxml2)

    Hello.
    May someone who knows how to use kxml help me please?
    I'll try to be straight forward. (Please excuse my imperfect English)
    My xml file look something like this:
    <?xml version="1.0" encoding="utf-8"?>
    <sample_tag1 xmlns:mysample="http://www.sample001.com/sample01schema">
    <feature name=”tag1_feature”>
         <test name=”xxxxx” id=”200” message=”Hello.”></test>
    </feature>
    <catalog name="shelf">
         <booklist name="book1" label="b1"></booklist>
         <booklist name="book2" label="b2"></booklist>
         <booklist name="book3" label="b3"></booklist>
    </catalog>
    </sample_tag1>
    And here's my code
              //http request
                   try{
                   //I can guarantee that the URL is valid
    httpConnection = (HttpConnection) Connector.open(URL);
    }catch(IOException ioe){
    ioe.printStackTrace();
                   //Create the parser
    KXmlParser parser = new KXmlParser();
    try{
                        //I use this code section to test if the xml file is properly placed in the inputStream.
    char[] tempChar = new char[500];
    isr = new InputStreamReader(httpConnection.openInputStream());
    isr.read(tempChar);
    for(int i=0; i<tempChar.length;i++){
    System.out.print(tempChar);
    //set the xml input
    parser.setInput(isr);
    //skip the "<?xml version="1.0" encoding="utf-8"?>" tag
    parser.nextTag();
    parser.require(XmlPullParser.START_TAG, null, "sample_tag1");
                        System.out.println("name : " + parser.getName());
    System.out.println("namespace : " + parser.getNamespace());
    parser.nextTag(); // ***1
    I compiled the app and run, here's the result:
    name : sample_tag1
    namespace :
    org.xmlpull.v1.XmlPullParserException: attr value delimiter missing! (position:START_TAG <feature name='http://www.sample001.com/sample01schema'>@3:15 in java.io.InputStreamReader@e938beb1)
    at org.kxml2.io.KXmlParser.exception(+47)
    at org.kxml2.io.KXmlParser.error(+45)
    at org.kxml2.io.KXmlParser.parseStartTag(+285)
    at org.kxml2.io.KXmlParser.nextImpl(+314)
    at org.kxml2.io.KXmlParser.next(+23)
    at org.kxml2.io.KXmlParser.nextTag(+24)
    at MyMidlet$ReadXML.run(MyMidlet.java:235)
    But when I comment the last line (parser.nextTag(); // ***1), here's the result:
    name : sample_tag1
    namespace :
    My code is the clone of the one in this tutorial:
    http://www.developer.com/ws/article.php/3759471
    where he get the weather forecast from Yahoo Weather RSS
    What did I do wrong? I tried looking up google for "attr value delimiter missing!" but found no useful information.
    Thank you in advance. =)

    Please read this topic. I posted an answer about parsing xml using kxml2
    http://forums.sun.com/thread.jspa?threadID=5291592&start=0&tstart=0
    Regards,
    David

  • How to parse XML in server side javascript (XSJS)?

    Hi Experts,
    I can get the XML file content through this method:var xmlString = $.response.body.asString() and I need to parse XML. If there XML parser in server side javascript? thanks very much!

    Hi Wenwen Hou,
    There is a blog available at
    Parse XML in server side javascript (XSJS)
    This can help you achieve parsing xml in server side javascript.
    Regards,
    Anjali.

  • How to parse xml string using JSTL

    Suppose this is my string:-----
    <books>
    <book>
    <title id=1>Book Title A</title>
    <author>A. B. C.</author>
    <price>17.95</price>
    </book>
    <book>
    <title id=2>Book Title B</title>
    <author>X. Y. Z.</author>
    <price>24.99</price>
    </book>
    </books>
    and I want to read title id = 1 then, how to parse it, I found tutorials regarding parsing simple xml document but how to parse attributes of a given XML

    But both of them either parse a file or data from an input source. I don't think they handle strings.An InputSource can be constructed with a Reader as input. One useful subclass of Reader is StringReader, so you'd use something likeDocument doc = documentBuilder.parse(new InputSource(new StringReader(myXMLString)));

  • Parsing xml using DOM parser in java

    hi there!!!
    i don have much idea about parsing xml.. i have an xml file which consists of details regarding indentation and spacing standards of C lang.. i need to read the file using DOM parser in java n store each of the attributes n elements in some data structure in java..
    need help as soon as possible!!!

    DOM is the easiest way to parse XML document, google for JDOM example it is very easy to implement.
    you need to know what is attribute, what is text content and what is Value in XML then easily you can parse your document with dom (watch for space[text#] in your XML document when you parse it).
    you get root node then nodelist of childs for root then go further inside, it is easy believe me.

  • How to compare after parsing xml file

    Hi,
    following code, parse the input.xml file, counts how many nodes are there and writes the node name and its value on screen.
    1) i am having trouble writing only node name into another file instead of writing to screen.
    2) after parsing, i like to compare each node name with another .xsd file for existence.
    Please keep in mind that, input.xml is based on some other .xsd and after parsing i have comparing its tag with another .xsd
    Need you help guys.
    thanks
    * CompareTags.java
    import java.io.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    /** This class represents short example how to parse XML file,
    * get XML nodes values and its values.<br><br>
    * It implements method to save XML document to XML file too
    public class CompareTags {
    private final static String xmlFileName = "C:/input.xml";
         int totalelements = 0;
    /** Creates a new instance of ParseXMLFile */
    public CompareTags() {
    // parse XML file -> XML document will be build
    Document doc = parseFile(xmlFileName);
    // get root node of xml tree structure
    Node root = doc.getDocumentElement();
    // write node and its child nodes into System.out
    System.out.println("Statemend of XML document...");
    writeDocumentToOutput(root,0);
                   System.out.println("totalelements in xyz tag " + totalelements);
              System.out.println("... end of statement");
    /** Returns element value
    * @param elem element (it is XML tag)
    * @return Element value otherwise empty String
    public final static String getElementValue( Node elem ) {
    Node kid;
    if( elem != null){
    if (elem.hasChildNodes()){
    for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){
    if( kid.getNodeType() == Node.TEXT_NODE ){
    return kid.getNodeValue();
    return "";
    private String getIndentSpaces(int indent) {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < indent; i++) {
    buffer.append(" ");
    return buffer.toString();
    /** Writes node and all child nodes into System.out
    * @param node XML node from from XML tree wrom which will output statement start
    * @param indent number of spaces used to indent output
    public void writeDocumentToOutput(Node node,int indent) {
    // get element name
    String nodeName = node.getNodeName();
    // get element value
    String nodeValue = getElementValue(node);
    // get attributes of element
    NamedNodeMap attributes = node.getAttributes();
    System.out.println(getIndentSpaces(indent) + "NodeName: " + nodeName + ", NodeValue: " + nodeValue);
    for (int i = 0; i < attributes.getLength(); i++) {
    Node attribute = attributes.item(i);
    System.out.println(getIndentSpaces(indent + 2) + "AttributeName: " + attribute.getNodeName() + ", attributeValue: " + attribute.getNodeValue());
    // write all child nodes recursively
    NodeList children = node.getChildNodes();
              //int totalelements = 0;
    for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
                   //     System.out.println("child value.."+child);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
    writeDocumentToOutput(child,indent + 2);
                             if(node.getNodeName() == "DATA"){
                             totalelements = totalelements+1;}
                        //System.out.println("totalelements in DATA tag " + totalelements);
    /** Parses XML file and returns XML document.
    * @param fileName XML file to parse
    * @return XML document or <B>null</B> if error occured
    public Document parseFile(String fileName) {
    System.out.println("Parsing XML file... " + fileName);
    DocumentBuilder docBuilder;
    Document doc = null;
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setIgnoringElementContentWhitespace(true);
    try {
    docBuilder = docBuilderFactory.newDocumentBuilder();
    catch (ParserConfigurationException e) {
    System.out.println("Wrong parser configuration: " + e.getMessage());
    return null;
    File sourceFile = new File(fileName);
    try {
    doc = docBuilder.parse(sourceFile);
    catch (SAXException e) {
    System.out.println("Wrong XML file structure: " + e.getMessage());
    return null;
    catch (IOException e) {
    System.out.println("Could not read source file: " + e.getMessage());
    System.out.println("XML file parsed");
    return doc;
    /** Starts XML parsing example
    * @param args the command line arguments
    public static void main(String[] args) {
    new CompareTags();
    }

    hi,
    check out the following links
    Check this blog to extract from XML:
    /people/kamaljeet.kharbanda/blog/2005/09/16/xi-bi-integration
    http://help.sap.com/saphelp_nw04/helpdata/en/fe/65d03b3f34d172e10000000a11402f/frameset.htm
    Check thi link for Extract from any DB:
    http://help.sap.com/saphelp_nw04s/helpdata/en/58/54f9c1562d104c9465dabd816f3f24/content.htm
    regards
    harikrishna N

  • Parsing xml payload and edit it

    Hi
    I am trying to parse xml payload in sender side.I have inserted a stateless session bean before " local ejbs call sap adapter".But changes made to string are not reflected in xml file.The code written in ejb is as follows
    package com.cts.xi;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import javax.ejb.CreateException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import org.dom4j.Document;
    import org.dom4j.DocumentException;
    import org.dom4j.DocumentHelper;
    import org.dom4j.Element;
    import com.sap.aii.af.mp.module.Module;
    import com.sap.aii.af.mp.module.ModuleContext;
    import com.sap.aii.af.mp.module.ModuleData;
    import com.sap.aii.af.ra.ms.api.Message;
    import com.sap.aii.af.ra.ms.api.PayloadFormatException;
    import com.sap.aii.af.ra.ms.api.XMLPayload;
    @ejbLocal <{com.cts.xi.EjbLocal}>
    @ejbLocalHome <{com.cts.xi.EjbLocalHome}>
    @stateless
    @transactionType Container
    public class EjbBean implements SessionBean, Module {
         public void ejbRemove() {
         public void ejbActivate() {
         public void ejbPassivate() {
         public void setSessionContext(SessionContext context) {
              myContext = context;
         private SessionContext myContext;
    Create Method.
         public void ejbCreate() throws CreateException {
              // TODO : Implement
         /* (non-Javadoc)
    @see com.sap.aii.af.mp.module.Module#process(com.sap.aii.af.mp.module.ModuleContext, com.sap.aii.af.mp.module.ModuleData)
         public ModuleData process(ModuleContext mc, ModuleData md) {
              // TODO Auto-generated method stub
              Message msg = (Message) md.getPrincipalData();
              XMLPayload pl = msg.getDocument();
              String str = null;
              String str1 = null;
              int m = 0;
              str = new String(pl.getContent());
              /*int[] ra = null;
              for (int i = 0; i < 4; i++) {
                   ra<i> = Integer.parseInt(mc.getContextData("rate"));
              try {
                   File f1 = new File("
    pciib04530
    USERS
    piyush
    test1.xml");
                   FileOutputStream fout1;
                   fout1 = new FileOutputStream(f1);
                   fout1.write(str.getBytes());
                   fout1.close();
              } catch (RuntimeException e2) {
                   // TODO Auto-generated catch block
                   e2.printStackTrace();
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              try {
                   Document doc = DocumentHelper.parseText(str);
                   Element root = doc.getRootElement();
                   str1 = traverseXML(root, str1,m);
              } catch (DocumentException e3) {
                   // TODO Auto-generated catch block
                   e3.printStackTrace();
              try {
                   File f6 = new File("
    pciib04530
    USERS
    piyush
    test6.txt");
                   FileOutputStream fout6;
                   fout6 = new FileOutputStream(f6);
                   //fout2.write(rt.getBytes());
                   //fout2.write(str1.getBytes());
                   //fout2.write(str2.getBytes());
                   //fout2.write(str3.getBytes());
                   fout6.write(str1.getBytes());
                   fout6.close();
              } catch (FileNotFoundException e4) {
                   // TODO Auto-generated catch block
                   e4.printStackTrace();
              } catch (IOException e4) {
                   // TODO Auto-generated catch block
                   e4.printStackTrace();
              try {
                   pl.setText(str);
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              try {
                   msg.setDocument(pl);
              } catch (PayloadFormatException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
              md.setPrincipalData(msg);
              return md;
    @param root
    @param str1
         private String traverseXML(Element e, String str1,int m) {
              // TODO Auto-generated method stub
              int spc = 0;
              String tmp = null;
              String tmp1 = null;
              tmp1 = str1;
              tmp = e.getName();
              String tmp3 = new String("SIPIR");
              if (tmp3.equals(e.getName())) {
                   int l = Integer.parseInt(e.getStringValue());
                   e.setName("SI");
                    int k = l * 3;
                   m++;
              str1 += tmp;
              /*for(int i=0;i<e.nodeCount();i++){
                   Element e1=e.elements().get(i);
              for (int j = 0; j < e.attributeCount(); j++) {
                   str1 += e.attribute(j).getName();
                   str1 += e.attribute(j).getData();
              for (int i = 0; i < e.elements().size(); i++) {
                   Element e1 = (Element) e.elements().get(i);
                   spc += 3;
                   traverseXML(e1, str1,m);
                   spc -= 3;
              return str1;
    Thanking you in advance.
    Regards
    piyush

    xml or plist , just the extension differs.(Both are Extended Markup Language).
    If u want to edit it manually - u can use property list editor (which is in XCode )
    or u can open with dashcode , which can be edited easily.
    If ur question was to edit dynamically.
    U can do that with write to file functionality.
    For example u may check this.
    http://www.iphonedevsdk.com/forum/iphone-sdk-development/1613-read-write-create- data-files.html

  • 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}

  • Parse XML files

    Hi
    Anyone know about support for parsing XML files in LabVIEW?
    (I mean specific XML support, I'm familiar with LabVIEWs file functions)
    regards
    Jan
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    I assume you are referring to:
    http://www.savarese.org/oro/software/OROMatcher1.1.html
    Have you considered asking Savarese?
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com
    +1.617.623.5782
    WebLogic Consulting Available
    "Laurent Mentek" <[email protected]> wrote in message
    news:[email protected]..
    Hi all,
    I'm started to develop with BEA WebLogic and I use ORACLE 8.1.6
    database.
    We need to map some XML tags as metadata in the database.
    Here is a concrete example with part of our XML files:
    XML files :
    <target>EDU</target>
    <question>
    <para>
    Please could you provide some references on nutritional status in
    the frail elderly?
    </para>
    </question>
    I use OROMatcher to parse xml files and it work fine.
    I can extract every element in line with success , but don't extract the
    value in <para> tag, for example.
    I don't no how to use the MULTILINE_MASK option and the ^ or $ to get
    this line.
    Anyone could give me an example of metadatas extaction using or no the
    MULTILINE_MASK option?
    Thanks a lot for your help.
    Laurent.

  • Parsing XML Files to ABAP

    Hello All,
    There is a requirement for parsing of XML files to ABAP.
    1.How do we pick an XML file from Application server and also from FTP server?
    2.After picking the XML file how to parse that XML file to process it to create material master?

    Hi,
    Ur scenario is File to R/3
    For creating material master ..i guess there is IDoc named MATMAS.
    U can make use of it and execute File to IDoc Scenario.
    link for File to IDoc--
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/fileToIDOC&
    U need to pick XML file from FTP server...No need to parse XML file...just create data type which represents ur xml file structure and map it to IDoc fields.
    regards,
    Manisha

  • How to parse xml in sap abap

    Hello,
    Can anyone help me to know how to parse xml in sap abap.
    I have a xml file which i want to parse and store it in internal table.
    <?xml version="1.0" encoding="UTF-8"?>##<data><name>menaka<name></data>
    Regards,
    Menaka.H.B

    Hello,
    For how to get the node name, you have to refer to this :
    [https://wiki.sdn.sap.com/wiki/display/ABAP/Upload%20XML%20file%20to%20internal%20table|https://wiki.sdn.sap.com/wiki/display/ABAP/Upload%20XML%20file%20to%20internal%20table]
    Check the code after:
    WHEN if_ixml_node=>co_node_element
    It tells you how to get the node name.
    BR,
    Suhas

Maybe you are looking for

  • How do I get a large mp4 file off of my phone?

    1--Its too big to upload to GDrive (presumably because it can't create a swap file) 2--I can no longer mount the phone as a USB Mass storage device in order to just drag it off to my desktop (thanks to one of Verizon's later Android updates). 3--Veri

  • Error while changing Billing document

    while opening billing document in VF02 i got got error " Period 001/2011 id not open for account type S  and G/L 1600261" can u tell what is that error and how to solve?

  • Utilization - Additional Excise in Depot Sales

    Hi SD Gurus Could u plz throw some light on, how the Additional Excise Duty is settled from Manufacturing Plant, in Depot Sales Process. Please be specific in your response as I have already completed the whole process till J1IJ and RG23D updation. A

  • I get an audio sound when my S5 connects to a wifi source.  How do I stop the sound?

    I get an audio sound when my S5 connects to a wifi source.  How do I stop the sound?

  • Caching in Acrobat Reader

    I keep running into an issue with Acrobat Reader.   We use a lot of PDFs on out site and sometimes, when I change one of them anyone who had viewed at file recently sees a cached copy of the old file rather than the updated PDF.  Is there an easy sol