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.

Similar Messages

  • Filling tab of an XML document created by DOM

    have a problem with filling tab of an XML file created by DOM
    I used this code to create the document:
    public class DOMCreation {
    public void createDOM( String a, String b ) {
              Document doc = new DocumentImpl( null );
              // Il codice che segue � indipendente dal particolare parser utilizzato
              // Creazione dell'elemento root del documento, identificato dal tag <DOCUMENT>
              Element root = doc.createElement("DOCUMENT");
              doc.appendChild(root);
              // Creazione ed inserimento di un nodo
              Element element1 = doc.createElement("USERNAME");
              root.appendChild( element1 );
              // Creazione ed inserimento di un secondo nodo discendente di <DOCUMENT>
              root.appendChild( doc.createElement("PIN") );
    System.out.println( a );
    System.out.println( b );
              try {
                   serializeDocument( doc, new FileOutputStream("d:/doc.xml"));
              } catch (FileNotFoundException e) {}
    private static void serializeDocument(Document doc, OutputStream output) {
              try {
                   DOMSerializer ser = new XMLSerializer( output, null);
                   ser.serialize(doc);
              } catch (IOException e) {
                   System.err.println("I/O exception while serializing document: " + e.getMessage());
    }

    The code lines:
    System.out.println( a );
    System.out.println( b );
    had the purpose to check if these two parameters were passed by another procedure. These two parameters, however, represent the content to be filled in the tag of XML document created by DOM.
    About the other question on "what parser do you use", I'm using Apache's Xerces. However that's the "import" that I include in this procedure:
    import org.apache.xerces.dom.DocumentImpl;
    import org.apache.xerces.dom.NodeIteratorImpl;
    import org.apache.xml.serialize.*;
    import org.w3c.dom.*;
    import org.w3c.dom.traversal.*;
    import java.io.*;

  • Parse XML document which have xlink/xpointer inside

    dear friends,
    There are lots of topic talking about parse xml, validating xml with schema and so on, but no one or any book talking about parsing xml document which can parse document with link inside.
    According to Mr Meggison at http://www.megginson.com/Background/
    we can do it, but he is not expert with this thing.
    For example I have 3 XML document. My main XML document, let named it A.XML have XPointer inside and this element pointing to B.XML and C.XML using xpointer. how to parse A.XML and in the same time my SAX recognized this XPointer and parse also element inside B.XML and C.XML.
    I am really grateull for any helpful information from you.
    best regards

    I think you need to look for a SAX or DOM parser that undestands XPointers and knows how to follow them to additional content.
    I have used XSLT and specified external documents to it. It knows how to read a document and in effect make a nodeset which can be searched with the XPath capabilities of XSLT.
    It sounds like you wnat an <include file="xxx"/> capability and have the parser stop reading the current file, and start reading the second file.
    That works in Schemas, but I'm unaware of any way to do it with SAX or DOM in one pass.
    It would not be too hard to process the first file, say with DOM.
    After the Document is built, go find the <include> elements, read get the attribute needed, build a new Document and merge it into the original Document in place of the <include> element.
    Is this more what you want to do?
    Dave Patterson

  • Can I create a Stored Procedure That access data from tables of another servers?

    I'm developing a procedure and within it I'm trying to access another server and make a select into a table that belongs to this another server. When I compile this procedure I have this error message: " PLS-00904: insufficient privilege to access object BC.CADPAP", where BC.CADPAP is the problematic table.
    How can I use more than one connection into an Oracle Stored Procedure?
    How I can access tables of a server from a Stored Procedure since the moment I'm already connected with another server?
    Can I create a Stored Procedure That access data from tables of another servers?

    You need to have a Database Link between two servers. Then you could do execute that statement without any problem. Try to create a database link with the help of
    CREATE DATABASE LINK command. Refer Document for further details

  • FDMEE Import error "No periods were identified for loading data into table 'AIF_EBS_GL_BALANCES_STG'

    Hi,
    We are having trouble while importing one ledger 'GERMANY EUR GGAAP'. It works for Dec 2014 but while trying to import data for 2015 it gives an error.
    Import error shows " RuntimeError: No periods were identified for loading data into table 'AIF_EBS_GL_BALANCES_STG'."
    I tried all Knowledge docs from Oracle support but no luck. Please help us resolving this issue as its occurring in our Production system.
    I also checked all period settings under Data Management> Setup> Integration Setup > Global Mapping and Source Mapping and they all look correct.
    Also its only happening to one ledger rest all ledgers are working fine without any issues.
    Thanks

    Hi,
    there are some Support documents related to this issue.
    I would suggest you have a look to them.
    Regards

  • How can I load data into table with SQL*LOADER

    how can I load data into table with SQL*LOADER
    when column data length more than 255 bytes?
    when column exceed 255 ,data can not be insert into table by SQL*LOADER
    CREATE TABLE A (
    A VARCHAR2 ( 10 ) ,
    B VARCHAR2 ( 10 ) ,
    C VARCHAR2 ( 10 ) ,
    E VARCHAR2 ( 2000 ) );
    control file:
    load data
    append into table A
    fields terminated by X'09'
    (A , B , C , E )
    SQL*LOADER command:
    sqlldr test/test control=A_ctl.txt data=A.xls log=b.log
    datafile:
    column E is more than 255bytes
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)

    Check this out.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1006961

  • How to insert row in table control and save the data in tables

    Hi,
    I have one table control i am displaying data into table control ,
    my problem is : i want to display data into read mode in table control.
    but when i click on insert button on the same screen i want one blank line should inserted into table control , then i want to insert some data into table control on that row , when i click the save button . the new data inserted into the table control is insert that data into ztable ,
    please give me solution
    main problen is  how can know inserted line in table control and pass that data into ztable.

    Hi,
    Follow the below logic,
    PROCESS BEFORE OUTPUT.
      MODULE STATUS_0001.
      MODULE POPULATE_TABLE_CONTROL. --> Get the data from table store in 
                                                                          ITAB
      LOOP AT GT_CTRL_LP_D516 INTO GS_WA_CTRL_LP_D516
           WITH CONTROL CTRL_LP_D516
           CURSOR CTRL_LP_D516-CURRENT_LINE.
      The following module moves data to control
        MODULE MOVE_TO_CONTROL.--> Move data from ITAB to table control
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP AT GT_CTRL_LP_D516.
      ENDLOOP.
      MODULE EXIT AT EXIT-COMMAND.
      MODULE USER_COMMAND_0001.  --> Here you have to take out the values from table control and update database table
    Reward points if helpful.
    Thanks and regards,
    Mallareddy Rayapureddy,
    Munich, Germany.

  • Parsing XML document with nested elements into multiple db tables(master-detail)

    Can you help me with storing xml document into master-detail tables?
    I have two tables:
    1) customers (customerid number primary key, firstname varchar2(30),lastname varchar2(30))
    2) cust_addresses (customerid number references customers, street varchar2(30),city varchar2(30),state varchar2(10),zip varchar2(10))
    I have XML document:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW num="1">
    <CUSTOMERID>1044</CUSTOMERID>
    <FIRSTNAME>Paul</FIRSTNAME>
    <LASTNAME>Astoria</LASTNAME>
    <HOMEADDRESS>
    <STREET>123 Cherry Lane</STREET>
    <CITY>SF</CITY>
    <STATE>CA</STATE>
    <ZIP>94132</ZIP>
    </HOMEADDRESS>
    <HOMEADDRESS>
    <STREET>N.Fryda 4</STREET>
    <CITY>CB</CITY>
    <STATE>CZ</STATE>
    <ZIP>37005</ZIP>
    </HOMEADDRESS>
    </ROW>
    </ROWSET>
    I know that I must use DBSM_XMLSave package, create view and instead of trigger but I did found no example in documentation.
    Thanx.

    Interested question; one I do not know the answer to at the moment, I am afraid. I would like to know your results.
    To tell others, though, what I have done. I did finally adapt Muench's not-yet-published examples #71 to work with a table. Here the table has as it's value "#{backing_app_EPG_DAYPG.jobDayDriverTable[row.Id1]}"
    This accesses a hash map defined in the backing bean as follows:
    public Map jobDayDriverTable = new HashMap(){
    @Override
    public Object get(Object key) {
    Number jobDayId = (Number)key;
    if (getEpgDayPage().jobDayDrivers(jobDayId) != null) {
    return getEpgDayPage().jobDayDrivers(jobDayId).getAllRowsInRange();
    else return null;
    jobDayDrivers returns RowIterator. From this I call getAllRowsInRange which returns a Row[]. The table consumes this as a value, and lists the values as I want.
    Since the table is using Rows for its rows, I am guessing that it would have access to #{row.rowKeyStr}, or at least #{row.<pk>} which would allow you to programmatically set the current row using code like the following:
    public static boolean setCurrentRow() {
    // BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    // bindings.getOperationBinding("setCurrentRowWithKey");
    (OperationBinding)EL.get("#{bindings.setCurrentRowWithKey}");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return false;
    return true;
    You could call this as part of code in a pages backing bean behind a button or link.
    Hope this helps somebody.
    By the way example #71 was to get a detail set of rows from a master row value and display the detail set in the master row of an af:table.
    You can find this and other examples at http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html

  • How to parse XML document returned by webservices

    Hi,
    I have a form (version 10.1.2.0) which has to display the credit card types using webservices. I created the webstub and jar file through jdeveloper and then after adding the jar files in the respective classpaths, I import it in the forms. I write the code in when-button-pressed and it gives the result in xml document like this:
    <?xml version="1.0" encoding="UTF-8"?><WSAnswerTO><error>false</error><errorMessage></errorMessage><
    results><CardTypeTO><carTypId>3</carTypId><type>AMERICAN
    EXPRESS</type><numLength>15</numLength><cvvLength>4</cvvLength><comments>1 800-639-0002</comments></CardTypeTO><CardTypeTO><carTypId>4</carTypId><type>DISCOVER</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-347-2683</comments></CardTypeTO><CardTypeTO><carTypId>1</carTypId><type>MASTERCARD</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-633-7367</comments></CardTypeTO><CardTypeTO><carTypId>2</carTypId><type>VISA</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-945-2000</comments></CardTypeTO></results></WSAnswerTO>
    From the above xml document, I only need to display the type (such as AMERICAN EXPRESS, VISA, ETC) in my forms. Can somebody please tell me how to do it. Do I need to store the values in a table first and then retrieve it. Please advise. I have already read a otn document in xml parsing but I didnt understand anything from it.
    Please help. Thanks in advance.

    Hello,
    It probably exists a database package/function to parse this kind of stuff.
    If you want to keep the process into the Forms, here is a PL/SQL package you can use:
    CREATE OR REPLACE PACKAGE Pkg_Tools AS
      --  Types  --
      -- table of strings --
      TYPE TYP_TAB_CHAR IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
      --  Methodes   --
      -- function that return all contents for a given XML tag --
      FUNCTION Get_Xml_Tag
         PC$XmlContent  IN VARCHAR2,                 -- XML string
         PC$Tag         IN VARCHAR2,                 -- searched tag
         PC$NewLine     IN VARCHAR2 DEFAULT CHR(10)  -- defaull NL character
      RETURN TYP_TAB_CHAR ;
    END Pkg_Tools;
    CREATE OR REPLACE PACKAGE BODY Pkg_Tools
    IS
      -- fonction de retour du contenu d'une balise XML  --
      FUNCTION Get_Xml_Tag
         PC$XmlContent  IN VARCHAR2,                 -- contenu XML
         PC$Tag         IN VARCHAR2,                 -- tag recherche
         PC$NewLine     IN VARCHAR2 DEFAULT CHR(10)  -- defaull NL character
      RETURN TYP_TAB_CHAR
      IS
       TC$Table      TYP_TAB_CHAR ;
       LC$Ligne      VARCHAR2(32000) ;
       LC$Xml        VARCHAR2(32000) ;
       LN$INDEX      PLS_INTEGER := 0 ;
       LN$TagDeb     PLS_INTEGER ;
       LN$TagFin     PLS_INTEGER ;
       LN$TagLength  PLS_INTEGER ;
       LN$LigLength  PLS_INTEGER ;
       LN$Occur      PLS_INTEGER := 1 ;
      BEGIN
        IF ( PC$XmlContent IS NOT NULL AND PC$Tag IS NOT NULL ) THEN
          LC$Xml := REPLACE( PC$XmlContent, CHR(13), '' ) ;
          LN$TagLength := LENGTH( PC$Tag ) ;
           LOOP
          LN$TagDeb := INSTR( LC$Xml, PC$Tag, 1, LN$Occur ) ;
          LN$TagFin := INSTR( LC$Xml, '</' || SUBSTR(PC$Tag,2, 256), 1, LN$Occur ) ;
          LN$LigLength := (LN$TagFin - ( LN$TagDeb + LN$TagLength ) ) ;
          IF (LN$TagDeb > 0 AND LN$TagFin > 0 ) THEN
             LN$Occur := LN$Occur + 1 ;
             LC$Ligne := SUBSTR( LC$Xml, LN$TagDeb + LN$TagLength, LN$LigLength ) ;
             LOOP
               LN$INDEX := LN$INDEX + 1 ;
               LN$TagDeb := INSTR( LC$Ligne, PC$NewLine ) ;
               IF LN$TagDeb > 0 THEN
                 IF Trim( SUBSTR( LC$Ligne, 1, LN$TagDeb - 1 )) IS NOT NULL THEN
                   TC$Table(LN$INDEX) := SUBSTR( LC$Ligne, 1, LN$TagDeb - 1 ) ;
                 ELSE
                   LN$INDEX := LN$INDEX - 1 ;
                 END IF ;
                 LC$Ligne := SUBSTR( LC$Ligne, LN$Tagdeb + LENGTH( PC$NewLine ), 30000 ) ;
               ELSE
                 IF Trim(LC$Ligne) IS NOT NULL THEN
                    TC$Table(LN$INDEX) := LC$Ligne ;
                 END IF ;
                 EXIT ;
               END IF ;
             END LOOP ;
          ELSE
              EXIT ;
          END IF ;
           END LOOP ;
        END IF ;
        RETURN TC$Table ;
      END Get_Xml_Tag ;
    END Pkg_Tools;
    /Then the call:
    DECLARE
       LC$t  VARCHAR2(2000);
       LT$Table Pkg_Tools.TYP_TAB_CHAR ;
    BEGIN
       lc$t := '<?xml version="1.0" encoding="UTF-8"?><WSAnswerTO><error>false</error><errorMessage></errorMessage><results>'
    ||'<CardTypeTO><carTypId>3</carTypId><TYPE>AMERICAN EXPRESS</TYPE><numLength>15</numLength><cvvLength>4</cvvLength>'
    ||'<comments>1 800-639-0002</comments></CardTypeTO><CardTypeTO><carTypId>4</carTypId><TYPE>DISCOVER</TYPE>'
    ||'<numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-347-2683</comments></CardTypeTO>'
    ||'<CardTypeTO><carTypId>1</carTypId><TYPE>MASTERCARD</TYPE><numLength>16</numLength><cvvLength>3</cvvLength>'
    ||'<comments>1 800-633-7367</comments></CardTypeTO><CardTypeTO><carTypId>2</carTypId><TYPE>VISA</TYPE>'
    ||'<numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-945-2000</comments></CardTypeTO></results></WSAnswerTO>' ;
       LT$Table := Pkg_Tools.Get_Xml_Tag(LC$T,'<TYPE>') ; 
       IF LT$Table.COUNT > 0 THEN
         FOR i IN LT$Table.First .. LT$Table.Last LOOP
            dbms_output.put_line( 'Table(' || i || ')=' || LT$Table(i) ) ;
         END LOOP ;
       ELSE
         dbms_output.put_line( 'tag xml not found' ) ;
       END IF ;
    END;Francois

  • No default attributes while Parsing XML document

    Hellow.
    I have such a problem:
    I have XML document that uses XSD-schema.
    In XSD-schema there is element that have two atributes:
    <xsd:complexType name = "El1">
          <xsd:attribute name = "atr1" xsd:default = "0" type = "xsd:boolean"/>
          <xsd:attribute name = "atr2" default = "0" type = "xsd:boolean"/>
    </xsd:complexType>And in XML document I write:
    <El1 atr1 = "1"/>According to the XSD-schema parser must add to El1 second attribute "atr2" with its default value because it has default value. But when I do such a code:
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    doc = builder.parse(new File("file1.xml"));
    Element pEl;
    pEl = doc.getDocumentElement()
    NamedNodeMap Attribs = pEl.getAttributes();In the list of attributes "Attribs" - there is no attribute "attr1"!!!
    What I have to do???

    Hello All
    I am new to this parsing world. I have a doubt. I have an XML like
    <xml>
    <platform name = "windows">
    <computer>
    <hostname> hostname1 </hostname>
    <IPAddress>127.0.3.03 </IPAddress>
    </computer>
    <computer>
    <hostname> hostname2 </hostname>
    <IPAddress>127.0.3.04 </IPAddress>
    </computer>
    </platform>
    <platform name = "unix">
    <computer>
    <hostname> hostname6 </hostname>
    <IPAddress>127.0.3.08 </IPAddress>
    </computer>
    <computer>
    <hostname> hostname7 </hostname>
    <IPAddress>127.0.3.09 </IPAddress>
    </computer>
    </platform>
    </xml>
    If i want to get details about individual computer under each platform as a string how do i do that?
    Which parser would be ideal to be used DOM or SAX.

  • Parsing xml document

    <?xml version="1.0" ?>
    </result>
    <response xmlns="http://comnet.com/namespaces/wcm/appint/1.0">      <objectset>
    <objectstore>                               <id>{275F7BDB-6F42-4CC1-99A3-59134AE30C38}</id>                <name>Alaska</name>
         <properties>
         <property>
         <name>Display Name</name>                     <value>Alaska</value>                     <symname>DisplayName</symname>                <datatype>8</datatype>
         </property>
                   </properties>
    </objectstore>
    <objectstore>                               <id>{98FA40B5-A425-4092-85D4-9BBD61A77E6F}</id>                <name>Yukon Territory</name>
              <properties>
         <property>
         <name>Display Name</name>                <value>Yukon Territory</value>                <symname>DisplayName</symname> <datatype>8</datatype>
    </property>
    </properties>      </objectstore>
    <count>2</count>
    </objectset>
    </response>
    </result>
    </appintresponse>
    hi this my xml document.i trying to parse this document..
    i need to display the id and name values of each objectstore tag in a select box
    id as option value and name as option text.
    iam doing like this..
    e = doc.getDocumentElement();
    list = e.getElementsByTagName("name");
    for(int i = 0; i < list.getLength(); i++)
    n = list.item(i);
    if(n.hasChildNodes())
    list2 = n.getChildNodes();
    for(int j = 0; j < list2.getLength(); j++)
    n2 = list2.item(j);
    String name =n2.getNodeValue();
                                                      out.println(name);
    it displaying the name but also its displaying the value which is name tag of property element..how can i avoid this..
    regards,

    as <id> is a child of <ObjectStore> it would seem that you should getElementsByName("ObjectStore") first, then find the id and name children.

  • Problem with XML document created by JDBC Sender adapter

    We are using a sender JDBC adapter to publish data out of a DB2 table.  The message generated by the XI sender adapter seems to have 2 extra characters that break our mapper.  You can see the characters (the dashes on lines 2 and 4) in the XML document that I copied from message monitoring.  Once I remove these dashes and test the mapper in test mode, it works.  If I test with the dashes, the mapper fails. Has anybody else seen this issue?
    Regards,
    Ivailo
      <?xml version="1.0" encoding="utf-8" ?>
    - <ns:CUSTOMER_SCOPE xmlns:ns="http://com.gatx/xi/RCRepairEstimate">
    - <row>
      <CM_CUST_GROUP_CODE>2915</CM_CUST_GROUP_CODE>
      <CM_CUST_SUB_CODE>2</CM_CUST_SUB_CODE>
      <CM_CUST_ID />
      <CM_TERMS>30</CM_TERMS>
      <CM_CUST_SHIPTO_GRP>2915</CM_CUST_SHIPTO_GRP>
      <CM_CUST_SHIPTO_SUB>2</CM_CUST_SHIPTO_SUB>
      <CM_BILL_NAME>GATX RAIL/CANADA</CM_BILL_NAME>
      <CM_BILL_ADDR1>540 5TH AVENUE SW SUITE 1225</CM_BILL_ADDR1>
      <CM_BILL_ADDR2 />
      <CM_BILL_ADDR3 />
      <CM_BILL_CITY>CALGARY ALBERTA</CM_BILL_CITY>
      <CM_BILL_STATE />
      <CM_BILL_ZIP5>0</CM_BILL_ZIP5>
      <CM_BILL_ZIP4>0</CM_BILL_ZIP4>
      <CM_FOREIGN_ZIP>T2P 0M2</CM_FOREIGN_ZIP>
      <CM_ATTENTION>AL FREDERIKSEN</CM_ATTENTION>
      <CM_SALESMAN_INI />
      <CM_DB_RATING />
      <CM_CRED_LIMIT>0</CM_CRED_LIMIT>
      <CM_CRED_FLAG />
      <CM_LAST_CHG_DATE>1282005</CM_LAST_CHG_DATE>
      <CM_CHANGED_BY_USER>XSKISSEL</CM_CHANGED_BY_USER>
      <CM_REORG_CODE>N</CM_REORG_CODE>
      <CM_CORP_GROUP_CODE>0</CM_CORP_GROUP_CODE>
      <CM_CORP_SUB_CODE>0</CM_CORP_SUB_CODE>
      <CM_RECORD_CODE />
      </row>
      </ns:CUSTOMER_SCOPE>

    Hi Ivailo,
    I think the problem lies in the way you copy the data from monitor.
    whenever you want to copy data from XI monitor to test in your IB,make sure you select "view source" and then copy the source message otherwise you will get the browser view of the XML document which contain those "-" for expanding and collapsing the document.
    Regards,
    Sridhar

  • How to ignore white space when parse xml document using xerces 2.4.0

    When I run the program with the xml given below the following error comes.
    Problem parsing the file.java.lang.NullPointerExceptionjava.lang.NullPointerExce
    ption
    at SchemaTest.main(SchemaTest.java:25)
    ============================================================
    My expectation is "RECEIPT". Pls send me the solution.
    import org.apache.xerces.parsers.DOMParser;
    import org.xml.sax.InputSource;
    import java.io.*;
    import org.xml.sax.ErrorHandler;
    import org.w3c.dom.*;
    public class SchemaTest {
    public static void main (String args[])
    try
    FileInputStream is = new FileInputStream(new File("C:\\ADL\\imsmanifest.xml"));
    InputSource in = new InputSource(is);
    DOMParser parser = new DOMParser();
    //parser.setFeature("http://xml.org/sax/features/validation", false);
    //parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", "memory.xsd");
    //ErrorHandler errors = new ErrorHandler();
    //parser.setErrorHandler(errors);
    parser.parse(in);
    Document manifest = parser.getDocument();
    manifest.normalize();
    NodeList nl = manifest.getElementsByTagName("organization");
    System.out.println((((nl.item(0)).getChildNodes()).item(0)).getFirstChild().getNodeValue());
    catch (Exception e)
    System.out.print("Problem parsing the file."+e.toString());
    e.printStackTrace();
    <?xml version = '1.0'?>
    <organizations default="detail">
    <organization identifier="detail" isvisible="true">
    <title>RECEIPT</title>
    <item identifier="S100000" identifierref="R100000" isvisible="true">
    <title>Basic Module</title>
    <item identifier="S100001" identifierref="R100001" isvisible="true">
    <title>Objectives</title>
    <metadata/>
    </item>
    </item>
    <metadata/>
    </organization>
    </organizations>
    Is there a white space problem? How do I get rid from this problem.

    ok now i really wrote the whole code, a bit scrolling in the API is to hard?
                DocumentBuilderFactory dbf = new DocumentBuilderFactory();
                DocumentBuilder db = dbf.newDocumentBuilder();
                dbf.setNamespaceAware(true); //or set false
                Document d = db.parse(inputstream);

  • Parse xml document with xpath

    I would like to parse an xml document using xpath, see:
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    however, in the documentation (in the link above), it states that I need J2SE 5.0.
    Currently, I have:
    $ java -version
    java version "1.5.0_11"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)
    Does that mean that I really have to install J2SE 5.0 in order to use J2SE 5.0's XPath support? Does anybody know anything about getting started with XPath, and whether I can just use my existing version of Java? I've never used XPath.
    For more documentation, one can view:
    http://www.w3.org/TR/xpath20/
    Thank you.

    I have copied the code for the xpath tutorial on
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    exactly as it is on the tutorial, and imported the correct jars (I think).
    But still my code is giving lots of errors!
    Granted its my first shot but anyway here's the code and the errors...
    package test;
    import org.jdom.xpath.*;
    import java.io.*;
    import javax.xml.xpath.*;
    public class XPath {
         public static void main (String [] args){
              XPathFactory factory = XPathFactory.newInstance();
              XPath xPath=factory.newXPath();
              XPathExpression  xPathExpression=xPath.compile("/catalog/journal/article[@date='January-2004']/title");
              File xmlDocument = new File("/home/myrmen/workspace/Testing/test/catalog.xml");     
              //FileInputStream fis = new FileInputStream(xmldocument); 
              InputSource inputSource = new InputSource(new FileInputStream(xmlDocument));
              String title = xPathExpression.evaluate(inputSource);
              String publisher = xPath.evaluate("/catalog/journal/@publisher", inputSource);
              String expression="/catalog/journal/article";
              NodeSet nodes = (NodeSet) xPath.evaluate(expression, inputSource, XPathConstants.NODESET);
              NodeList nodeList=(NodeList)nodes;
              SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
              org.jdom.Document jdomDocument = saxBuilder.build(xmlDocument);
              org.jdom.Attribute levelNode = (org.jdom.Attribute)(XPath.selectSingleNode(jdomDocument,"/catalog//journal[@title='JavaTechnology']" + "//article[@date='January-2004']/@level"));
              levelNode.setValue("Intermediate");
              org.jdom.Element titleNode = (org.jdom.Element) XPath.selectSingleNode( jdomDocument,"/catalog//journal//article[@date='January-2004']/title");
              titleNode.setText("Service Oriented Architecture Frameworks");
              java.util.List nodeList = XPath.selectNodes(jdomDocument,"/catalog//journal[@title='Java Technology']//article");
              Iterator iter=nodeList.iterator();
              while(iter.hasNext()) {
                   org.jdom.Element element = (org.jdom.Element) iter.next();
                   element.setAttribute("section", "Java Technology");
              XPath xpath = XPath.newInstance("/catalog//journal:journal//article/@journal:level");
              xpath.addNamespace("journal", "http://www.w3.org/2001/XMLSchema-Instance");
              levelNode = (org.jdom.Attribute) xpath.selectSingleNode(jdomDocument);
              levelNode.setValue("Advanced");
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         Type mismatch: cannot convert from XPath to XPath
         The method compile(String) is undefined for the type XPath
         InputSource cannot be resolved to a type
         InputSource cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeList cannot be resolved to a type
         NodeList cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         The method selectSingleNode(Document, String) is undefined for the type XPath
         The method selectSingleNode(Document, String) is undefined for the type XPath
         Duplicate local variable nodeList
         The method selectNodes(Document, String) is undefined for the type XPath
         Iterator cannot be resolved to a type
         The method newInstance(String) is undefined for the type XPath
         The method addNamespace(String, String) is undefined for the type XPath
         The method selectSingleNode(Document) is undefined for the type XPath
         at test.XPath.main(XPath.java:12)

  • Using parser to parse xml document

    Hi all:
    I have a xml document which has a root element and the a list of elements(same type) underneath it.
    My question is:
    Is there a restriction on the number of elements(same type) that you can extract from the Document?
    Thanks.
    Rino

    If you use DOM of JDOM, you will have a problem when you run out of system memory.
    If you use SAX, the parser will throw events with the required data for the current node (element, data, attribute). Once the event has been processed, the data is out of scope (unless you still hold a reference to it).
    If you use SAX, you are able to process each node without keeping the data from that node any longer than you like. Unless you have to have the entire document available, I would suggest using SAX.

Maybe you are looking for

  • Company code ZG01 is not assigned to a fiELD status variant

    HI, I have created company called 'zg01'. when i try to create a GL ACCOUNT FOR this company using (FS00) i am getting the following error. Company code ZG01 is not assigned to a fiELD status variant. FOR YOUR INFORMATION I HAVE CREATED COA  and assi

  • After update from Windows 8 to 8.1 wifi if off

    Hi! I haw Lenovo ideapad s310 with Qualcomm Atheros AR9485WB-EG Wireless Network Adapter driver version is (date 10/17/2013 / version 10.0.0.270 from atheros.cz) After update my Windows 8 to 8.1 the wifi is turned off and i don't know haw it turn on.

  • Batch Management Implementation in Cement Industry.

    Dear All I would like to understand about Batch Management Implementation in Cement Industry. I have some inputs on Batch Management but from Implementation in Cement Industry would like to exactly understand what are the typical scenarios for Batch

  • Giving name to existing oracle error number in my code

    I need to handle the array error on a bulk insert . Is there any danger in doing the following? The error -24381 is NOT my custom error but a standard oracle error. Package Header PRAGMA EXCEPTION_INIT(array_dml_error, -24381); Package Body BULK INSE

  • Tablet won't activate

    When I start up my tablet it goes straight to the software update page and says retry activation your tablet could not be activated because of error (2012). I have tried to update it with the desktop software but it won't let me because it says I nee