Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert a file to xml

14 views
Skip to first unread message

new2javaguy

unread,
Mar 18, 2005, 6:17:59 PM3/18/05
to
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

unread,
Mar 25, 2005, 11:57:56 AM3/25/05
to
> 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
Strange hierarchy....

>
> <Class :Thing>
> <Class :KoalaWithPhD>
> <Class :MaleStudentWith3Daughters>
> <Class :Habitat>
> ....
> .....
> </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

0 new messages