How to restore this kinda XML into an array or list?

I have a XML file like this
[msgboard]
[message]
[subject] subject [/subject]
[body] text body [/body]
[followups]
    [message]
        [subject] subject [/subject]
        [body] text body [/body]
        [followups]
                   [message] ...
        [/followups]
    [/message]
[followups]
[/message]
[/msgboard]so the XML can be unlimited deap.
I want to read it into an array or list or something like that, so I can use the data.. but how should I store them? any ideas ? thanks

Please refrain from cross posting http://forum.java.sun.com/thread.jspa?threadID=785000

Similar Messages

  • How to parse this kind of XML documents and store in a relational tables

    Can u guys help me out ,..how to parse these kind of XML documents..like under PR there Sr,CreationDate and DoBID.. Again under Sr...there are LD, CID,TID, RID and so on.....
    so how to parse this kind of data..how to create the structure of the table....pls help me out..
    <nk8:PR>
              <nk8:Sr>
                   <nk8:LD>---------</nk8:LID>
                   <nk8:CID>---------</nk8:CID>
                   <nk8:TID>---------</nk8:TID>
                   <nk8:RID>---------</nk8:RID>
                   <nk8:CC>OnError</nk8:CC>
                   <nk8:AID>---------</nk8:AID>
              </nk8:Sr>
              <nk8:CreationDateTime>2002-07-01</nk8:CreationDateTime>
              <nk8:DOBID>---------</nk8:DOBID>
         </nk8:PR>
         <ssm:ER>
              <ssm:PN>---------</ssm:PN>
              <ssm:SN>---------</ssm:SN>
              <ssm:SCt>---------</ssm:SC>
              <ssm:IA>
                   <ssm:NT>---------</ssm:NT>
                   <nk8:LID>---------</nk8:LID>
                   <nk8:CID>---------</nk8:CID>
                   <ssm:AN>---------</ssm:AN>
              </ssm:A>
         </ssm:ER>
         </nk8:PR>

    First, your XML document is not well formatted. Once you're done with that you can extract the values and store it in a table column.
    sql> WITH xml_table AS
      2  (SELECT XMLTYPE(
      3  '
      4  <nk8:PR xmlns:nk8="http://www.w3.org">
      5  <nk8:Sr>
      6  <nk8:LID>LID Value</nk8:LID>
      7  <nk8:CID>CID Value</nk8:CID>
      8  <nk8:TID>TID Value</nk8:TID>
      9  <nk8:RID>RID Value</nk8:RID>
    10  <nk8:CC>OnError</nk8:CC>
    11  <nk8:AID>---------</nk8:AID>
    12  </nk8:Sr>
    13  </nk8:PR>') XMLCOL FROM DUAL)
    14  SELECT extractvalue(t.column_value,'//nk8:LID','xmlns:nk8="http://www.w3.org"') "LID",
    15   extractvalue(t.column_value,'//nk8:CID','xmlns:nk8="http://www.w3.org"') "CID",
    16   extractvalue(t.column_value,'//nk8:RID','xmlns:nk8="http://www.w3.org"') "RID",
    17  extractvalue(t.column_value,'//nk8:CC','xmlns:nk8="http://www.w3.org"') "CC"
    18  FROM xml_table, table(xmlsequence(extract(xmlcol,'/nk8:PR/nk8:Sr','xmlns:nk8="http://www.w3.org"'))) t;
    LID        CID        RID        CC
    LID Value  CID Value  RID Value  OnError

  • On my iPad home screen, the mail app used to indicate the number of new emails I had with a number in a red circle.  This has vanished since I upgraded.  Does anyone know why, and how to restore this?

    On my IPad 2 home screen, the mail app used to indicate the number of new messages with a number in a red circle, next to the app.  This has vanished, I think about the same time as when I upgraded to the new OS.  Does anyone know why and how to restore this feature? 

    Thanks.  While you were replying to my question, I went into notifications and figured
    it out.  Appreciate the quick response!

  • How to realize this kind of ALV(with two headerlines)?

    Dear all:
      could anyony provide some advice on how to realize this kind of ALV?
    |--|--
    field2
    |--|||--
         field11  |  field12   |  field21  |  field212      |
    |--|||--
    wait your kindly advice

    I had similar kind of requirement. Have a look at below code. It will help you. You can execute it. You can see the report output which contains two header lines.
    REPORT  ztestvib    MESSAGE-ID zz  LINE-SIZE 50.
    TYPE-POOLS: slis.
    DATA: x_fieldcat TYPE slis_fieldcat_alv,
          it_fieldcat TYPE slis_t_fieldcat_alv,
          l_layout TYPE slis_layout_alv,
          x_events TYPE slis_alv_event,
          it_events TYPE slis_t_event.
    DATA: BEGIN OF itab OCCURS 0,
          vbeln LIKE vbak-vbeln,
          posnr LIKE vbap-posnr,
          male TYPE i,
          female TYPE i,
         END OF itab.
    SELECT vbeln
           posnr
           FROM vbap
           UP TO 20 ROWS
           INTO TABLE itab.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 1.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 2.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'MALE'.
    x_fieldcat-seltext_l = 'MALE'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'FEMALE'.
    x_fieldcat-seltext_l = 'FEMALE'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_events-name = slis_ev_top_of_page.
    x_events-form = 'TOP_OF_PAGE'.
    APPEND x_events  TO it_events.
    CLEAR x_events .
    l_layout-no_colhead = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        i_callback_program = sy-repid
        is_layout          = l_layout
        it_fieldcat        = it_fieldcat
        it_events          = it_events
      TABLES
        t_outtab           = itab
      EXCEPTIONS
        program_error      = 1
        OTHERS             = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    *&      Form  top_of_page
          text
    FORM top_of_page.
    *-To display the headers for main list
      FORMAT COLOR COL_HEADING.
      WRITE: / sy-uline(103).
      WRITE: /   sy-vline,
            (8) ' ' ,
                 sy-vline,
            (8)  ' ' ,
                 sy-vline,
            (19) '***'(015) CENTERED,
                 sy-vline.
      WRITE: /   sy-vline,
            (8) 'VBELN'(013) ,
                 sy-vline,
            (8) 'POSNR'(014) ,
                 sy-vline,
            (8) 'MALE'(016) ,
                 sy-vline,
             (8)  'FMALE'(017) ,
                 sy-vline.
      FORMAT COLOR OFF.
    ENDFORM.                    "top_of_page
    The header lines are as below:
    VBELN      POSNR      MALE       FMALE
    I hope it helps.
    Best Regards,
    Vibha
    *Please mark all the helpful answers

  • How to restore the FM Bands into iTunes?

    How to restore the FM Bands into iTunes?

    FM Bands?  Are you talking about the Radio category of iTunes?
    B-rock

  • I cannot see the Organize bookmarks link in Bookmarks Tab, how to restore this

    I am to export the bookmarks to an html file. But I am not able to view the organize bookmarks tab in the Bookmarks tab. How to restore this tab.

    "Organize Bookmarks" has been renamed to "Show All Bookmarks" in the bookmarks menu.

  • How to get this kind number?

    I have a float number,e.g myfloat=123.34???. When the first "?">=5,
    myfloat=123.35,or myfloat=123.34.Can anyone tell me how to get this kind number.
    Thanks in advance.

    In fact, not very clear of your problem.
    Supposing you want to get fix position's value after ".",
    you could firsly convert it to a string,
    then position "." ,use subString() to get the value.
    compare it, reconvert it back.

  • How to break up a String into multiple array Strings?

    How do I break up a string into a bunch of String arrays after the line ends.
    For example,
    JTextArea area = new JTextArea();
    this is a string that i have entered in the area declared above
    now here is another sting that is in the same string/text area
    this is all being placed in one text field
    Sting input = area.getText();
    now how do I break that up into an array of strings after each line ends?

    Ok I tested it out and it works.
    So for future refrence to those that come by the same problem I had:
    To split up a string when using a textfield or textarea so that you can store seperate sections of the string based on sperate lines, using the following code:
    String text = area.getText() ;
    String[] lines = text.split("\n") ;
    This will store the following
    this is all one
    entered string
    into two arrays
    Cheers{
    Edited by: watwatacrazy on Oct 21, 2008 11:06 AM
    Edited by: watwatacrazy on Oct 21, 2008 11:16 AM
    Edited by: watwatacrazy on Oct 21, 2008 11:16 AM

  • How to restore iphone from an old back up not listed?

    Hello,
    I've read all through this forumn but still can't quite work out my problem - which is probably simple for peeps with apple smarts...
    i backed up my iphone last week on my laptop in anticipation of updating to iSO5.0.1.
    so today I updated to 5.0.1 on my home desktop, and could have sworn i backed up correctly, but it didn't so it restored to a year ago, it had -50 error now that i think about it.
    i thought its still okay as i knew i had a recent backup on my laptop. When i connected my iphone, it synced and apparently backed it up. now cant seem to work out how to restore to an older back up - it only list the one today.
    can someone tell me how i can restore to a back up that is not listed (only todays is) as i really want my contacts and calendar back?
    any help would be greatly appreciate,
    jackie

    i need to restore it from an earlier back up... is this possible???
    It isn't an issue if you still have the backup, either on your computer or in the iCloud. You cannot restore to a backup that you have deleted.

  • How to retrieve values in XML into a plsql table type

    Hi
    I have an XML doc like below which is a Web Service response message.
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Body>
    <GetOrgInput xmlns="http://www.example.org/ComplianceServices">
    <ProgramName>PgmA-PgmB</ProgramName>
    <ItemName>800 ADSL</ItemName>
    <Orgs>923</Orgs>
    <Orgs>1163</Orgs>
    <Orgs>1103</Orgs>
    </GetOrgInput>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    From the above doc you could see that i have multiple occurrences of "Orgs" element. Usually i am using the .extract and .getSTringVal() to retrieve the values as below.
    l_string_variable := p_response.doc.extract('//'||p_name||'/child::text()',p_namespace).getStringVal();
    But in this case if i do that, i am getting value as 92311631103. I need to get them into a table type of number. Pls advice me on how to achieve this.
    Thanks
    PKV

    I'm guessing this is a bug that Oracle fixed when 10.2 came out. I can reproduce your lack of results on 10.1.0.4 and as my post above shows, it works correctly on 10.2.0.4.
    Here's a modification to the script that shows what is going on as I was debugging this. (It took me a bit to realize the difference as it wasn't what I was expecting)
    declare
       p_response_doc XMLTYPE;
       l_new_doc      XMLTYPE;
    begin
       p_response_doc := XMLTYPE('<?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <GetOrgOutput xmlns="http://www.example.org/ComplianceServices">
    <CompliantOrgs>1163</CompliantOrgs>
    <CompliantOrgs>1103</CompliantOrgs>
    </GetOrgOutput>
    </soapenv:Body>
    </soapenv:Envelope>');
       SELECT p_response_doc.extract('/*/*/*/CompliantOrgs','xmlns="http://www.example.org/ComplianceServices"')
         INTO l_new_doc
          FROM dual;
       dbms_output.put_line(l_new_doc.getStringVal());
       dbms_output.put_line('before loop');
       FOR r_rec IN (SELECT value(t) val
    --   FOR r_rec IN (SELECT extractvalue(value(t)
    --      , '/CompliantOrgs'
    --      , 'xmlns="http://www.example.org/ComplianceServices"' ) val
          -- BULK COLLECT INTO l_nm_array
          FROM TABLE(
            XMLSequence(
              p_response_doc.extract('/*/*/*/CompliantOrgs','xmlns="http://www.example.org/ComplianceServices"')
            ) t
       ) LOOP
          dbms_output.put_line(r_rec.val.getStringVal());
    --      dbms_output.put_line(r_rec.val);
       END LOOP;
       dbms_output.put_line('After output');
    end;On 10.2.0.4 this produces
    <CompliantOrgs xmlns="http://www.example.org/ComplianceServices">1163</CompliantOrgs>
    <CompliantOrgs xmlns="http://www.example.org/ComplianceServices">1103</CompliantOrgs>
    before loop
    <CompliantOrgs xmlns="http://www.example.org/ComplianceServices">1163</CompliantOrgs>
    <CompliantOrgs xmlns="http://www.example.org/ComplianceServices">1103</CompliantOrgs>
    After outputOn 10.1.0.4 it produces
    <CompliantOrgs xmlns="http://www.example.org/ComplianceServices">1163</CompliantOrgs>
    <Complian tOrgs xmlns="http://www.example.org/ComplianceServices">1103</CompliantOrgs>
    before loop
    <CompliantOrgs>1163</CompliantOrgs>
    <CompliantOrgs>1103</CompliantOrgs>
    After outputAs you can see, Oracle is removing (well technically not adding) the default namespace to the extracted nodes. To compensate, you need to change your loop to look like
       FOR r_rec IN (SELECT extractvalue(value(t)
          , '/CompliantOrgs') val
    --      , 'xmlns="http://www.example.org/ComplianceServices"' ) val
          -- BULK COLLECT INTO l_nm_array
          FROM TABLE(
            XMLSequence(
              p_response_doc.extract('//CompliantOrgs','xmlns="http://www.example.org/ComplianceServices"')
            ) t
       ) LOOPso that extractValue is not expecting any namespaces associated with the nodes.
    I would suggest you document this so you will know why things break if you upgrade to 10.2 or later at some point in the future.

  • Need to turn this lastName_Name_01_07_1980.xml into  Name LastName 01.07.80

    Hi all
    I am using this code to trim a string and place it into a jMenu. Now I would like to change the out the way is looks to make it easier to view.
    Like this:
    Need to turn this file name lastName_FirstName_01_07_1980.xml into FirstName LastName 01.07.80
    is this posible to do ?
    can some me how ?
      private void addItem(JMenu menu, char a)
      File dir = new File("Epod Configuration/Orders To Upload");
            File[] files = dir.listFiles();
            for (int j=0; j < files.length; j++)
                    String trim = ""+files[j];
                    int ndx;
                    if ((ndx = trim.lastIndexOf('/')) != -1) trim = trim.substring(ndx+1);
                    if (trim.charAt(0) == a)
                      System.out.println(trim);
                            JMenuItem mi = new JMenuItem(trim);
                            menu.add(mi);
      }Thanks
    Craig

    thanks for that
    but how do I put the two codes together ??
    the file name also has .xml at the end what is the bet way of getting rid of that
    this is what I have try but doesn't work
    Please help
    private void addItem(JMenu menu, char a)
        File dir = new File("Epod Configuration/Orders To Upload");
        File[] files = dir.listFiles();
        for (int j=0; j < files.length; j++)
          String trim = ""+files[j];
          int ndx;
          if ((ndx = trim.lastIndexOf('/')) != -1) trim = trim.substring(ndx+1);
          if (trim.charAt(0) == a)
            System.out.println(trim);
            String s = "lastName_FirstName_01_07_1980";
            StringTokenizer st = new StringTokenizer(s, "_");
            String last = st.nextToken();
            String first = st.nextToken();
            String month = st.nextToken();
            String day = st.nextToken();
            String year = st.nextToken();
            System.out.println(first + ' ' + last + ' ' + month + '.' + day + '.' + year);
            JMenuItem mi = new JMenuItem(trim);
            menu.add(mi);
      }

  • How do you load external XML into a dataProvider?

    I have been looking through the docs and have found a couple
    of entries discussing how to load external XML. Unfortunately, that
    is where the example stops and there is no example of doing
    anything useful with that data.
    I have managed thus far to get my XML file loaded into
    actionscript/flex:
    function getExternalXML():void {
    request = new URLRequest('source.xml');
    loader = new URLLoader();
    loader.load(request);
    loader.addEventListener("complete", loadXML);
    function loadXML(e:Event):void {
    combo.dataProvider = loader.data;
    obviously, the above doesn't work at all. I don't know how to
    convert the loader.data into a format that the
    ComboBox.dataProvider understands. I can't believe I have to write
    a function to parse this XML. Surely there must be a way to simply
    convert the XML to an array or something???

    That link uses the flex beta 3 docs. You may want to use the
    current livedocs.
    Here
    is a direct link to the section I was talking about.
    Scroll down about halfway to the part that says "However,
    using a raw data object..."
    If you want the PDFs (easier to read IMO) you can get them
    here.
    Here
    is a direct link to the Developer's Guide:

  • How to restore my Ipod touch into a new hard disk/computer?

    Guys, my Laptop's hard drive was crash and all my songs and applications were the only copy I had. However, I had no idea how to restore my musics and application back to the library after I had replace a new hard disk. I went through online to check out some solutions but basically they required a software to retrieve those music and they cost money. I don't think I deserve this since I had spent $70 to get a new hard disk. The worst was mostly they only able to restore musics and videos. I don't think they're able to restore the applications, please give me some advises. Thanks

    You should always maintain a backup. If you fail to do this you are asking to lose your data.
    You can transfer itunes purchases:
    File>Transfer Purchases
    Unlike music and videos, you can re-download apps:
    http://support.apple.com/kb/HT2519

  • How to restore my iPhone apps into new iTunes library ??

    I formated my PC recently and forgot to backup my iTunes library,when new login to iTunes on formated PC, the "Apps" page still can see all my Iphone Apps that installed before but all the apps icon on right hand side show in non active icon, when I tick the "Sync Apps" on the top left corner, the box "Are you want to Sync apps ? All existing apps and their data on the iphone " x's iphone" will be replace with apps from this iTunes library" , means if i click "Sync Apps" all my previous apps will gone !!! Anybody know how to restore the apps from my iPhone to iTunes library, so i can continue to Sync new apps while maintain my old apps.
    Thanks You Very Much

    Alright... i get the answer already ..... just follow the link below :
    http://support.apple.com/kb/HT1848?viewlocale=en_US
    for my case, after Authorize Computer just click "file" from iTunes and select [Transfer Purchases from "x's iPhone"] , the iTunes will start transfer your iPhone apps to iTunes library. simple ...

  • How to conver this sqlserver code into Oracle

    Hi,
    Any one can help me how to covert below sqlserver code into Oracle?
    DECLARE @t1 DATETIME;
    DECLARE @t2 DATETIME;
    SET @t1 = GETDATE();
    select * from table;
    SET @t2 = GETDATE();
    SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;

    Hi,
    Do Like This ,
    This is The function going to calculate elapsed time ,execute this before the second script,
    CREATE function DATEDIFF
      startTime in timestamp with time zone,
      endTime in timestamp with time zone
    return number
    as
      interval_ interval day (9) to second (3);
    begin
      interval_ := endTime - startTime;
      return (extract(day from (interval_)) * 86400 +
             extract(hour from (interval_)) * 3600 +
             extract(minute from (interval_)) * 60 +
             extract(second from (interval_))) * 1000;
    end;And this Is the Script that i converted to oracle,
    SET server out put on;
    DECLARE
       v_t1         TIMESTAMP;
       v_t2         TIMESTAMP;
       lv_cur       sys_refcursor;
       lv_elapsed   VARCHAR2 (30);
    BEGIN
       v_t1 := SYSTIMESTAMP;
       OPEN lv_cur FOR
          SELECT *
            FROM emp;
       v_t2 := SYSTIMESTAMP;
       SELECT datediff (v_t1, v_t2) elapsed_ms
         INTO lv_elapsed
         FROM DUAL;
       DBMS_OUTPUT.put_line (v_t1);
       DBMS_OUTPUT.put_line (v_t2);
    END;Thanks & Rgds
    BCV.

Maybe you are looking for

  • All roads lead to Rome: Can't download ADE for Mac OS 10.6.8

    ADE 4.0 requires Mac OS 10.7.  All Adobe help and forum answers send me to Adobe Digital Editions downloads.  Pressing the link to ADE 2.0 or 3.0 sends me to a blank page.  Is it possible to use ADE on my MacBook using its stable current OS 10.6.8 or

  • Post-import method /SAPCND/TRN_AFTER_IMPORT_OW error in XPRA_EXECUTION

    Has any one come acroos the error is in Post-import method /SAPCND/TRN_AFTER_IMPORT_OW, while trying to apply the Enhancement Package 1 for SOLMAN, This was in phase XPRA_EXECUTION...The error is in SAPKNA7016... We did come across SAP note Note 1064

  • Mouse icon disappears!

    Sometimes when I am using photoshop CS3 or flash 9 standalone (and other applications too) the mouse icon disappears. In photoshop when I move my mouse out of the canvas it goes away, to get the pointer back I hit command-tab to bring up the app swit

  • Major Update Problem

    hi can anyone please help. dreamweaver won't update - even though the updaters for 8.0.1 and 8.0.2 both say they've installed successfully and everything, then when I load dreamweaver up it's still just version 8 and still says patch update available

  • [SOLVED]Planning to Switch - Broadcom "?"

    I'm planning on switching from Ubuntu to Arch and am wondering what experiences have been like when dealing with Broadcom wireless cards.  In my experience they've been rather a pain to deal with and I just want to find out whether anyone can tell me