Reading a Flatfile and converting into XML Format


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Reading a Flatfile and converting into XML Format

  1. #1
    Join Date
    Jan 2008
    Posts
    2

    Reading a Flatfile and converting into XML Format

    Hi,

    I am new to JAVA.

    I have an input structure in the below format.



    Sl.No*Name*Salary

    101*Hari*45000

    102*Ram*30000

    103* * 25000



    I want XML format in the below format.



    <RecordSet>

    <Record1>

    <Sl.No> 101 </Sl.No>

    <Name> Hari </Name>

    <Salary> 45000</Salary>

    </Record1>

    <Record2>

    <Sl.No> 102 </Sl.No>

    <Name> Ram</Name>

    <Salary> 30000</Salary>

    </Record2>

    <Record3>

    <Sl.No> 102 </Sl.No>

    <Name> </Name>

    <Salary> 25000</Salary>

    </Record3>

    </Recordset>



    So, basically if I have 100records, it should populate 100 records in XML.



    In the above input file, * is the field separator and <NL> new line is the record separator.

    Any pointers are highly appreaciated.

    Regards,
    Lucky

  2. #2
    Join Date
    Mar 2007
    Location
    Bangalore, India
    Posts
    247
    Basically, read from the file using Scanner or use a StringTokenizer to get the values from the flat file, and use some API lik JaxB or Castor or something to get XML (or for this particular case, since there is no much complexity, you could use a FileWriter and directly output XML.

  3. #3
    Join Date
    Jan 2008
    Location
    Bucharest, Romania
    Posts
    1

    Smile an advice

    May be this link will help you:
    http://www.unidex.com/overview.htm
    I think it is older.
    May be these links are better for you?
    http://dan.somnea.free.fr/2C/xml.php
    http://dan.somnea.free.fr/2C/javaIDEs.php

    Happy trails,

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center