Solved

How to create xml using jaxp - java?

Posted on 2008-06-12
10
1,523 Views
Last Modified: 2013-11-23
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>
0
Comment
Question by:inditrozen
  • 5
  • 5
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 21767695
From what do you want to create it?
0
 

Author Comment

by:inditrozen
ID: 21767714
Actually I am taking xml element information from database.
0
 

Author Comment

by:inditrozen
ID: 21767769
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 21767800
What db are you using?
0
 

Author Comment

by:inditrozen
ID: 21767873
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 86

Expert Comment

by:CEHJ
ID: 21767960
If you have Java objects you'd probably be better off using something like XStream
0
 

Author Comment

by:inditrozen
ID: 21767994
Ya, I have java objects..
can you please suggest some good tutorial for XStream or some sample program .

thx..
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 21768085
XStream is pretty simple and well documented with samples in the download

http://xstream.codehaus.org/
0
 

Author Comment

by:inditrozen
ID: 21768156
thanks a lot
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21768240
:-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Basic Java Case or If-Else statement... 3 43
read an xml file in perl 2 15
servlet example 10 19
tomcat administrtor 12 34
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now