How to parse a dynamic xml in java

I have to parse a dynamic xml document : the different TheItemNames and the racine are changing . So , can you help me with a code because to parse a xml document you must presents the racine and TheItemNames

My previous post gives me an idea on how to use ArrayList of ArrayList as dynamic 2 dimensional array.
More info bellow
ArrayList rows = new ArrayList()
ArrayList columns_of_row0 = new ArrayList()
rows.insertAt(0) = columns_of_row0;
ArrayList columns_of_row1 = new ArrayList()
rows.insertAt(1) = columns_of_row1;and so on..
You can't use the code exactly or similar way, it would depend on how this array grows in your application.
But this and my previous post should give an idea on how to insert and retrieve elements from ArrayList when
treated as 2 dimensional array.
Hope this helps.

Similar Messages

  • How to parse contents from XML file in Java

    Hi All,
    I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
    How to parse Contents of XML file??
    Thanks in advance,
    Rajendra.

    Hi All,
    I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
    How to parse Contents of XML file??
    Thanks in advance,
    Rajendra.

  • How to parse the following xml file

    Hi
    I have an xml file with the following data
    Example.xml
    <?xml version="1.0" encoding="iso-8859-1"?>
    <html><set label="09/07/29" value="1241.90"/>
    </html>
    How do i retrive the values of the attributes
    Example i want the label value 09/07/29
    and 1241.90 to be inserted into some temp table.
    Appreciate if any one can provide me the solution.
    Thanks,

    it's more an XQuery question than DB XML one.
    Anyway, you can use the following queries to get attributes values:
    doc(<your_doc>)/html/set/@label
    doc(<your_doc>)/html/set/@valueYou can retrieve both values in a single query, but for this please refer to the XQuery specification.
    Or read: [http://www.oracle.com/technology/documentation/berkeley-db/xml/gsg_xml/java/xquery.html#xqueryintro]
    Best,
    Vyacheslav

  • How can (parse) i use XML file with missing EndTag

    hi,
    i have an application which writes an "XML file".
    another application should read that XML file, build an DOM and
    access the nodes with xpath.
    my problem. if the first application is not finished there are tags
    missing. e.g. </xml>. but the seconds application cannot wait until the first application finishes it task.
    if i now read the XML file the parser cannot load it because the end tags are missing.
    my question:
    how can i deactivate the check or how can i read the XML file and access it via XPath (my application is using at the moment XPath to access the nodes and i dont want to change that)
    as parser i am using XERCES
    alex

    As far as I know, you can't do this - xml must be well formed (this is sort of a bedrock of xml). There may be some work around's, but I'm not aware of any - and they would most likely be hacks.

  • How to read  and write XML in java

    I have a code that reads a large XML file, splits it into smaller files, filters and then writes it into a new XML file. My problem is that I had coded the input file name into the code, so that only the specified file can be read. How can I rewrite my code to be able to take any input xml and perform the same operation? Here's a portion of my code below:
                            File file = new File("c:\\APAdjustmentJVDoc_FINAL.xml");
                        output = new BufferedWriter(new FileWriter(file));
                        for (int i = 1; i < 79; i++) {
                             fIStream = new FileInputStream("c:\\APAdjustmentJVDoc_new" + i + ".xml");
                             loRead = new InputStreamReader(fIStream);
                             doc = XMLUtil.transformToNode(loRead, false);
                             System.out.println("Reading from file " + "c:\\APAdjustmentJVDoc_new" + i + ".xml");
                             writeFile(doc, docIdList, output);
                             fIStream.close();
                             loRead.close();
                        System.out.println("Output file complete");
                   } catch (Exception e) {
                        e.printStackTrace();
                   } finally {
                        if (output != null) {
                             output.close();
                        if (fIStream != null) {
                             fIStream.close();
              } catch (Exception e) {
                   e.printStackTrace();
                 

    You need to pass your filename String as a parameter to your functionality. It depends how you're currently set up though. We can't really see the top of your call so it's difficult to determine what you are calling and we don't really know from where you're calling either.
    If you're running standalone, then on launch of the application, you can feed in a file name as an argument that you can read in in String args[] in the main function and pass down to your XML splitter.
    If you're a method in a class that's part of a bigger pile, you can feed the file name as a String to the method from wherever you call from if it makes sense architecturally.
    You might also want to pass down a File object if that makes sense in your current code (i.e. if you're using your file for other purposes prior to the split, to avoid recreating closing/opening for no reason).
    Depends what you're trying to do. If I put together a piece like this, I would probably create an <yourcurrentrootpackage>.xml.splitter package.
    Also, on a side note, you're problem isn't really reading and writing XML in java, but seems more to be making your functionality generic so that any XML file can be split with your code.
    Regards
    JFM

  • How to parse the result xml string in BPEL

    Hi,
    This is Ishmayel.v new to BPEL and hava experience in xml parsing, java and webservices.
    Now I am getting the XML file as a result string in BEPL.
    now I want to parse the XML string and insert into the database... If any one has the idea let me know.
    my email id is [email protected]
    Thanks in Advance,
    Regards,
    Ishmayel.

    Your question is not clear.
    You have a client applicaton which invokes a BPEL process and receives XML response from BPEL. Then you want to parse this response XML in your client application?
    Or you are running a BPEL process which invokes a service and receives an XML response. Then you want to parse this XML response in BPEL before your process can proceed?
    I have to assume that you are working with a string and then you want to convert the string into XML, and then parse the XML. If this is the case, then take a look at the ora:parseEscapedXML(contentString) function. You can use this in the expression editor in JDev.

  • How to create/call dynamic XML feed from CFC - HELP PLEASE!!

    Hi All,
    First off I'm a newb to web services.  I'm trying to create the invoke a web service on a CFC for a XML feed.  When I call the CFC directly all looks fine and is correctly formatted etc:
    http://www.prevu.tv/cfc/xyzTest.cfc?method=listPlant
    Am I correct in outputting it in this way?  What if I output as a string instead......would others be able to consume it?
    When I try to invoke it as a web service I am getting an error I do not understand.  I am trying to call it using (user/pass not required in CFC):
    <cfinvoke webservice="test" method="listPlant" returnvariable="foo">
    <cfinvokeargument name="username" value="abc">
    <cfinvokeargument name="password" value="123">
    </cfinvoke>
    <cfoutput><cfdump var="#foo#"></cfoutput>
    Here is my CFC code:
    <cfcomponent>
        <cffunction name="listPlant" access="remote" returntype="xml" output="no">
        <cfargument name="username" type="string" required="no">
        <cfargument name="password" type="string" required="no">
            <cfquery datasource="#request.dsn#" name="getPlant">
            SELECT                *
            FROM                  plant
            INNER JOIN        plantaddress ON plant.plantID = plantaddress.plantID
            WHERE              icePlantID IS NULL
            AND                   categoryID NOT IN (9,10,11)
            AND                   statusID = 1
            AND                   activePlantList = 1
            ORDER BY        plant.plantID LIMIT 5
            </cfquery>
            <!---Convert Query to xml--->
            <cfprocessingdirective suppresswhitespace="Yes">
            <cfcontent type="text/xml; charset=utf-8">
            <cfxml variable="xmlobject">
            <PrevuPlant>
                <cfoutput query="getPlant">
                <Plant>
                    <PlantID>#plantID#</PlantID>
                    <PlantName>#XmlFormat(plantName)#</PlantName>
                    <Street>#XmlFormat(street)#</Street>
                    <Suburb>#XmlFormat(suburb)#</Suburb>   
                    <City>#XmlFormat(city)#</City>
                    <State>#XmlFormat(state)#</State>
                    <Country>#XmlFormat(country)#</Country>
                    <PostCode>#XmlFormat(postcode)#</PostCode>
                    <Latitude>#XmlFormat(latitude)#</Latitude>
                    <Longitude>#XmlFormat(longitude)#</Longitude>
                    <CountryCode>#XmlFormat(countryCode)#</CountryCode>
                    <AreaCode>#XmlFormat(areaCode)#</AreaCode>
                    <Phone>#XmlFormat(phone)#</Phone>
                    <Fax>#XmlFormat(fax)#</Fax>
                </Plant>
                 </cfoutput> 
            </PrevuPlant>
            </cfxml>
            <!---Convert back to a string--->
            <cfset myvar=toString(xmlobject)>
            </cfprocessingdirective>
        <cfreturn myvar>
        </cffunction>
    </cfcomponent>
    Can anyone please tell me where I am going wrong, or how the output for a XML feed called from a CFC should look in a browser etc?
    Thanks

    Hey Dan....thanks for the prompt reply.
    I added the wsdl and this is what I get when I call the service from this cfm page: http://www.prevu.tv/xyzTest.cfm
    Have never seen output like this.  Is this correct?
    The web service I'm writing is also for some .net developers so it may be that I need to output as string also - this discussion has not taken place yet.

  • How to bind dynamic xml with Java objects without xsd

    have a question, and hope someone here can help me.
    In my current project, I will get a xml file, containing some information of each user, and map them into a set of user objects.
    For each user, there are some fixed attributes, such as name, phone#, age, position, etc. The problem is, client can customize, and add new attibutes, such as address, favorite color, so there will be no xsd for the xml.
    What I want to do, is map fixed attributes to user object attributes, for example, name attribute to User.name, and they will have corresponding getters, and setters, but for custom attributes, I want to add them to a HashMap in User object, for example, use string "ADDRESS" as the key, and address as the value.
    Is there any way I can do this? Thank you very much for any help you can provide.

    It would not be too hard to do in regular code.
    First, make a HashSet with the Strings for the names of the known attributes that will be processed with setters.
    Then, get the NamedNodeMap via getAttributes(). That will give you all attributes -- both the ones you will handle with your setters and the ones you will handle via a HashMap.
    Then, loop through the NamedNodeMap. For each attribute, get the name and value. If the name is in the HashSet of known values, process it with a list of
    if ( attName.equals( "name" ))
        whatever.setName( value );
       continue;
    }If it is not in the HashSet, then set the value into your HashMap with the name and value.
    There is no standard way to do this.
    Dave Patterson

  • How to declare a dynamic array in java

    I have to use a dynmic array of boolean and the size of this array will defiend throuh the run of the program to explian
    boolean[][] a;
    a=new boolean[number_of_ raw][number_of_ culm];
    after the program run the number_of_ raw and number_of_ culm will defind..so if any body know how to declare this kind of arraies in java please help me.

    My previous post gives me an idea on how to use ArrayList of ArrayList as dynamic 2 dimensional array.
    More info bellow
    ArrayList rows = new ArrayList()
    ArrayList columns_of_row0 = new ArrayList()
    rows.insertAt(0) = columns_of_row0;
    ArrayList columns_of_row1 = new ArrayList()
    rows.insertAt(1) = columns_of_row1;and so on..
    You can't use the code exactly or similar way, it would depend on how this array grows in your application.
    But this and my previous post should give an idea on how to insert and retrieve elements from ArrayList when
    treated as 2 dimensional array.
    Hope this helps.

  • How to parse data from XML with prefix?

    Hi folks,
    I have an XML which tags include prefixes. I would like to parse it using a select. Any ideas?
    [Sample XML|http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_or.cgi?ico=46972501]
    I tried this:
    select xml
    from
       (  select
                httpuritype('wwwinfo.mfcr.cz/cgi-bin/ares/darv_or.cgi?ico=46972501').getXML() xml
          from dual
        );This just returns XML.
    select  x.ico,
            x.org_name
        from dual d
             ,XMLTABLE('/are:Ares_odpovedi/are:Odpoved/D:Vypis_OR'
                        PASSING httpuritype('http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_or.cgi?ico=46972501').getXML()
                        COLUMNS
                           ico varchar2(50) PATH 'D:ZAU/D:ICO'
                          ,org_name varchar2(200) PATH 'D:ZAU/D:OF'
                        )  x
       where rownum = 1
    ORA-19228: XPST0008 - undeclared identifier: prefix 'are' local-name 'are:Ares_odpovedi'Any idea how to simply get all details into columns?
    Thanks,
    Tomas

    add xmlnamespaces to xmltable
    select  x.ico,
            x.org_name
        from XMLTABLE(
             xmlnamespaces('http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_answer_or/v_1.0.3' as "are"
             , 'http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_datatypes/v_1.0.3' as "D"),
             '/are:Ares_odpovedi/are:Odpoved/D:Vypis_OR'
                        PASSING httpuritype('http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_or.cgi?ico=46972501').getXML()
                        COLUMNS
                           ico varchar2(50) PATH 'D:ZAU/D:ICO'
                          ,org_name varchar2(200) PATH 'D:Vypis_OR/D:ZAU/D:OF'
                        )  x
       where rownum = 1not tested

  • How to remove xmlns from xml using java

    Hi,
    <DLList xmlns="http://www.test.com/integration/feed" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Weather>
    <StateName>Karnataka</StateName>
    <ForecastName>Bagalkote</ForecastName>
    <Humidity>89.9</Humidity>
    </Weather>
    <Weather>
    <StateName>Karnataka</StateName>
    <ForecastName>Devengiri</ForecastName>
    <Humidity>89.9</Humidity>
    </Weather>
    </DLList>
    The above xml needs to be decomposed using xsu.I am facing a small problem because the xml has namespaces.
    How to remove the namespace using java to get the below xml
    Note:I am using XSLT for the transformation.The XSLT tag is not identifying the <DLList> tag with name space
    <DLList>
    <Weather>
    <StateName>Karnataka</StateName>
    <ForecastName>Bagalkote</ForecastName>
    <Humidity>89.9</Humidity>
    </Weather>
    <Weather>
    <StateName>Karnataka</StateName>
    <ForecastName>Devengiri</ForecastName>
    <Humidity>89.9</Humidity>
    </Weather>
    </DLList>
    Please help.Let me know if any other information is required
    Thanks

    OK, here goes :
    For the example, I'll use a TB_DISTRICT table with the following structure :
    create table tb_district (
    sr_no number(3),
    district_name varchar2(100)
    );loaded with data from this page :
    http://india.gov.in/knowindia/districts/andhra1.php?stateid=KA
    and this XML document (one additional record compared to the one you posted) :
    <DLList xmlns="http://www.test.com/integration/feed" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Weather>
    <StateName>Karnataka</StateName>
    <ForecastName>Bagalkote</ForecastName>
    <Humidity>89.9</Humidity>
    </Weather>
    <Weather>
    <StateName>Karnataka</StateName>
    <ForecastName>Devengiri</ForecastName>
    <Humidity>89.9</Humidity>
    </Weather>
    <Weather>
    <StateName>Karnataka</StateName>
    <ForecastName>Dharwad</ForecastName>
    <Humidity>70.1</Humidity>
    </Weather>
    </DLList>In order to access the XML, I'll also use this Oracle directory object :
    create directory test_dir as 'D:\ORACLE\test';Final relational tables are :
    create table BUSINESS_TABLE
      STATE         VARCHAR2(30),
      DISTRICT_NAME VARCHAR2(30),
      HUMIDITY      NUMBER
    );and
    create table REJECT_TABLE
      STATE         VARCHAR2(30),
      DISTRICT_NAME VARCHAR2(30),
      HUMIDITY      NUMBER,
      ERROR_MESSAGE VARCHAR2(500)
    );With XMLTable function, we can easily break the XML into relational rows and columns ready to use for DML :
    SQL> alter session set nls_numeric_characters=". ";
    Session altered
    SQL>
    SQL> SELECT *
      2  FROM XMLTable(
      3    XMLNamespaces(default 'http://www.test.com/integration/feed'),
      4    '/DLList/Weather'
      5    passing xmltype(bfilename('TEST_DIR','test.xml'), nls_charset_id('CHAR_CS'))
      6    columns
      7      state         varchar2(30) path 'StateName'
      8    , district_name varchar2(30) path 'ForecastName'
      9    , humidity      number       path 'Humidity'
    10  )
    11  ;
    STATE                          DISTRICT_NAME                    HUMIDITY
    Karnataka                      Bagalkote                            89.9
    Karnataka                      Devengiri                            89.9
    Karnataka                      Dharwad                              70.1
    Then with a multitable insert, we load both the business table and the reject table (if the district name does not exist in TB_DISTRICT) :
    SQL> INSERT FIRST
      2    WHEN master_district_name IS NOT NULL
      3      THEN INTO business_table (state, district_name, humidity)
      4                VALUES (state, district_name, humidity)
      5    ELSE INTO reject_table (state, district_name, humidity, error_message)
      6              VALUES (state, district_name, humidity, 'Invalid district name')
      7  WITH xml_data AS (
      8    SELECT *
      9    FROM XMLTable(
    10      XMLNamespaces(default 'http://www.test.com/integration/feed'),
    11      '/DLList/Weather'
    12      passing xmltype(bfilename('TEST_DIR','test.xml'), nls_charset_id('CHAR_CS'))
    13      columns
    14        state         varchar2(30) path 'StateName'
    15      , district_name varchar2(30) path 'ForecastName'
    16      , humidity      number       path 'Humidity'
    17    )
    18  )
    19  SELECT x.*
    20       , t.district_name as master_district_name
    21  FROM xml_data x
    22       LEFT OUTER JOIN tb_district t ON t.district_name = x.district_name
    23  ;
    3 rows inserted
    SQL> select * from business_table;
    STATE                          DISTRICT_NAME                    HUMIDITY
    Karnataka                      Dharwad                              70.1
    SQL> select * from reject_table;
    STATE                          DISTRICT_NAME                    HUMIDITY ERROR_MESSAGE
    Karnataka                      Bagalkote                            89.9 Invalid district name
    Karnataka                      Devengiri                            89.9 Invalid district name

  • How to parse PPT (PowerPoint) files in Java?

    Hello!
    I want to parse PPT files (PowerPoint presentation). All I want to do is get slides (frames) of the ppt files into my Java program.
    Is there a way to get slides as images from PPT files?

    wow.. i've found some intresting thing.. http://www.powerml.com/powerml-pro/doc/index.jsp
    I think it that I'm looking for. But i'm not sure if I can get slides as images from ppt files with PowerML... Ok.. I'll try to do it!

  • Unflattern in C#: How to parse LV-generated XML in CSharp?

    Hello,
    it is very easy to flattern an object (e.g. my cluster,...) to XML string in LabView!
    And it is also very easy to unflattern this XML string back to the object (to my cluster).
    What I want:
    1. Flattern Cluster in LabView to XML string
    2. Store in SQL Database
    3. Read (Unflattern) in C# Application
    e.g. my cluster consists of:
    1. integer: num1
    2. boolean: on
    3. array of clusters (bool, int): data1
    Question: How to unflattern the XML string in C#?
    Thank you verymuch in advance!
    BR
    EWiebe
    Eugen Wiebe
    Bernstein AG
    CLAD - Certified LabView Associate Developer
    Attachments:
    Flattern_Unflattern_in_LV.vi ‏10 KB

    I don't know anything about how C# treats XML.  However, if you have the XML file that LabVIEW produces, it is "human-readable", so you can print it out and look at it.  What does C# expect for its XML?  If you don't know, try generating a C# XML file with the same type of data that you used in LabVIEW (using analogous C# constructs).  Print that file out, as well.
    If everything were the Best in this Best of All Possible Worlds, the two files would be identical.  I'm going to guess that they'll be different, but (with luck) the differences will be (a) obvious and (b) "editable", that is, you should be able to make a "LabVIEW-to-C# XML Translator" that will transform the LabVIEW XML file to a form that C# can interpret.  Indeed, there may be XML features (analogous to Style Sheets) that will do this for you.
    Good Luck.
    BS

  • XML using Java

    Can anyone tell me how to parse n Save XML file using Java.

    Dont double post! http://forum.java.sun.com/thread.jspa?threadID=5268589

  • *URGENT * Parsing nd Searching XML with DOM

    Hi,
    I am Juliana, I am a new grad, a new employee and brand new to XML, I am learning to parse XML with the XML parser for PLSQL.
    Please anyone help me how to parse the following XML string so that I will display all the session and its time schedule, or if possible display only the session that I want to display.
    Thank you very much for any of your help
    Juliana
    <Student> Id="9130099">
    <Class>
    <Session>A-100</Session>
    <Session>A-200</Session>
    <Session>A-300</Session>
    <Session>A-400</Session>
    <session>A-500</Session>
    </Class>
    <Time> At:
    <At>10:30</At>
    <At>12:30</At>
    <At>02:30</At>
    <At>04:30</At>
    <At>05:30</At>
    </time>
    </Student>

    thx for the replay
    1) i thought of using xpath but wanted to know how to do it over DOM
    2) i mean that the 3 <item> have other element inside like that:
    <item>
    <title>Implementing Service-Oriented Architectures (SOA) with the Java EE 5 SDK</title>
      <link>http://java.sun.com/developer/technicalArticles/WebServices/soa3/?feed=JSC</link>
      <description>This article presents concepts and language constructs needed to develop a Service-Oriented Architecture composite application in Java EE 5. It then describes an example application designed to solve a business problem.</description>
      <date />
      </item>and all of them have <title>, <link> etc. I want to get the same values(eg. <title>) from all the 3 <item> and not including the <title> in the begining of xml
    3) i am a professional child.....joke....
    try to get to your sensitive side...thats way.

Maybe you are looking for

  • Report Painter: How to change the order of lines in selection screen

    Dear Gurus on Report Painter, how can I change the order of the lines (where the values for the variable selection of my cost center report are entered) in the selection screen of a report painter report? The Selection screen looks awful. Is there al

  • CUSTOM REPORT PROBLEM - REP-1213

    I am a student trying to complete a project. I developed a "custom" report form which uses 5 tables to generate the report. I have entered the 'fields' at various locations on the report form and when I run the report I get the following error messag

  • PLS-00306: wrong number or types of arguments in call in a for loop

    Dear all I recently put up another post about the same error message but as the message now relates to another part of my programme and, in my mind at least, a different conceptual idea, I thought I should start a new top. If that is not right thing

  • XML data not displayed with XSL

    I have just started learning XML so bear with me. I have a xml document that I created and want to use a stylesheet to display it in html but it doesn't seem to be working. Here is the xml file: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet

  • Best way to set up a Mac?

    Having used Leopard, I have decided it's no good for my work enviroment so am going to install Tiger on the new iMac's I have just received. But I have noticed a permissions problem with one I'm testing software out on. What I've done is installed Ti