-
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
-
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.
-
an advice
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks