Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2005

Tip: Looking for answers? Try searching our database.

Convert a file to xml

Thread view: 
new2javaguy - 19 Mar 2005 00:17 GMT
Hi,
I am completely new to java and i am trying to create a tree of an
output i have. generally the output is tab delimited and i have a
sample output as below.

Class :Thing
 Class :KoalaWithPhD
 Class :MaleStudentWith3Daughters
 Class :Habitat
   Class :Forest
     Class :Rainforest
     Class :DryEucalyptForest
   Class :University
 Class :Female
 Class :Student
   Class :GraduateStudent
 Class :Degree
 Class :Gender
 Class :Male

I want to create an xml out of it in the tree format as below

<Class :Thing>
  <Class :KoalaWithPhD>
  <Class :MaleStudentWith3Daughters>
  <Class :Habitat>
....
.....
</Class :Thing>

Can someone throw in a simple code snipet that can help me do this.
Really appreciate your help

Thanks
aks
Piet - 25 Mar 2005 17:57 GMT
> Class :Thing
>   Class :KoalaWithPhD
[quoted text clipped - 10 lines]
>   Class :Gender
>   Class :Male
Strange hierarchy....

> <Class :Thing>
>    <Class :KoalaWithPhD>
[quoted text clipped - 3 lines]
> .....
> </Class :Thing>
This is not an XML file, not even a snippet of it.
You may want to have a look at the following links
XML tutorial:
http://www.zvon.org/xxl/XMLTutorial/General/book.html
2. Java Tutorial
http://java.sun.com/docs/books/tutorial/getStarted/index.html
3. Java and XML
http://java.sun.com/xml/jaxp/docs.html
I guess that these two more specialized links will also be useful:
4. String handling tutorial in Java
http://java.sun.com/docs/books/tutorial/java/data/strings.html
5. Using stacks in Java
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Stack.html

HTH
Piet


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.