How to create xml using jaxp - java?

Hi Experts,

how can I create xml file using jaxp ?

sample xml file :
<?xml version="1.0"?>
<country name="xyz">
      <cities>
            <city name="Test1" id="1">
                  <address >
                        <street>str</street>
                        <number>1</number>
                  </address>
                  </datapoint>
            <city name="Test2"  id="2">
                  <address>
                        <street>str1</street>
                        <number>2</number>
                  </address>
            </city>
      </cities>
</country>
inditrozenAsked:
Who is Participating?
 
CEHJCommented:
XStream is pretty simple and well documented with samples in the download

http://xstream.codehaus.org/
0
 
CEHJCommented:
From what do you want to create it?
0
 
inditrozenAuthor Commented:
Actually I am taking xml element information from database.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
inditrozenAuthor Commented:
I am looking at the tutorial on http://www.javazoom.net/services/newsletter/xmlgeneration.html
(5) - JAXP + SAX + Serialization to servlet output stream : JDK 1.4 compliant -

but I dont get it completely that how can I add child elements
0
 
CEHJCommented:
What db are you using?
0
 
inditrozenAuthor Commented:
I think ,I asked in a wrong way, sorry for that.
I need to know how to use this jaxp.
say I have list of cities and all other is present in program.
0
 
CEHJCommented:
If you have Java objects you'd probably be better off using something like XStream
0
 
inditrozenAuthor Commented:
Ya, I have java objects..
can you please suggest some good tutorial for XStream or some sample program .

thx..
0
 
inditrozenAuthor Commented:
thanks a lot
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.