Results 1 to 3 of 3
  1. #1
    rmal is offline Member
    Join Date
    Jul 2013
    Posts
    1
    Rep Power
    0

    Default read xml files and write to the txt file

    Hi,
    My background is mainframe and i'm new to java. We're moving from mainframe to the java world and i'm trying to

    achieve a task. I have a main folder and then bunch of sub folders and each sub folder has bunch of xml files, files

    size are varies some of them are 900kb. I need to read these xml files and send the output to the txt file (comma

    separated). I would really appreciate if someone can put me on the right track and advise me some possible options or

    even sample example would be great. please find below the sample xml file. I need to extract information's only where

    FORM name="F00001".

    Java Code:
    <PACKET>
       <FORM name="F00001" sequence="0">
          <FIELD sequence="1">02</FIELD>
          <FIELD sequence="2">00000</FIELD>
          <FIELD sequence="3">CAB100</FIELD>
          <FIELD sequence="4">TEFAP001</FIELD>
          <FIELD sequence="5">EMPTY FIELD</FIELD>
          <FIELD sequence="6">009.999.989</FIELD>
          <FIELD sequence="7">03</FIELD>
          <FIELD sequence="8">P9999999999999</FIELD>
          <FIELD sequence="9">EMPTY FIELD</FIELD>
          <FIELD sequence="10">EMPTY FIELD</FIELD>
       </FORM>
       <FORM name="F99999" sequence="1"
          <FIELD sequence="1">TIM K.</FIELD>
          <FIELD sequence="2">PROFESSOR</FIELD>
          <FIELD sequence="3">DAVID P. PIT</FIELD>
          <FIELD sequence="4">ASST PROFESSOR</FIELD>
          <FIELD sequence="5">EMPTY FIELD</FIELD>
          <FIELD sequence="6">009.999.989</FIELD>
          <FIELD sequence="7">03</FIELD>
          <FIELD sequence="8">P9999999999999</FIELD>
          <FIELD sequence="9">EMPTY FIELD</FIELD>
          <FIELD sequence="10">EMPTY FIELD</FIELD>
       </FORM>
    </PACKET>
    <PACKET>
       <FORM name="F00001" sequence="0">
          <FIELD sequence="1">09</FIELD>
          <FIELD sequence="2">00999</FIELD>
          <FIELD sequence="3">CAB101</FIELD>
          <FIELD sequence="4">TEFAP9999</FIELD>
          <FIELD sequence="5">EMPTY FIELD</FIELD>
          <FIELD sequence="6">009.999.999</FIELD>
          <FIELD sequence="7">03</FIELD>
          <FIELD sequence="8">T9999999999999</FIELD>
          <FIELD sequence="9">EMPTY FIELD</FIELD>
          <FIELD sequence="10">EMPTY FIELD</FIELD>
       </FORM>
       <FORM name="F99998" sequence="1"
          <FIELD sequence="1">KIM T.</FIELD>
          <FIELD sequence="2">PROFESSOR</FIELD>
          <FIELD sequence="3">NATHAN B.</FIELD>
          <FIELD sequence="4">ASST PROFESSOR</FIELD>
          <FIELD sequence="5">EMPTY FIELD</FIELD>
          <FIELD sequence="6">009.999.989</FIELD>
          <FIELD sequence="7">08</FIELD>
          <FIELD sequence="8">P9999999999988</FIELD>
          <FIELD sequence="9">EMPTY FIELD</FIELD>
          <FIELD sequence="10">EMPTY FIELD</FIELD>
       </FORM>
    </PACKET>
    Thank you so much

    best regards
    rm

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: read xml files and write to the txt file

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    slider57 is offline Member
    Join Date
    Aug 2011
    Posts
    29
    Rep Power
    0

    Default Re: read xml files and write to the txt file

    you might want to look into the document builder factory.

    DocumentBuilder (Java 2 Platform SE 5.0)

    I also found another thread that talks about this same thing.

    Convert Document object to String object
    Last edited by slider57; 07-25-2013 at 08:02 PM.

Similar Threads

  1. Replies: 0
    Last Post: 07-25-2011, 06:16 PM
  2. Replies: 18
    Last Post: 05-02-2011, 06:37 PM
  3. Read/Write Files
    By FlyNn in forum New To Java
    Replies: 3
    Last Post: 02-06-2010, 09:45 PM
  4. How Read and Write XMl files using Java
    By tjs in forum SWT / JFace
    Replies: 0
    Last Post: 02-23-2009, 01:19 PM
  5. [SOLVED] Read/write files using applets
    By coolFrenzi in forum Advanced Java
    Replies: 3
    Last Post: 11-17-2008, 11:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •