File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes XML document create with Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "XML document create with Java" Watch "XML document create with Java" New topic

XML document create with Java

Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 331

Can some one tell me how to create a XML document like following in java (in php it looks like following)

To be more specific im try to build this google map app using java

Thank You.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
SAXParser is a good XML parser for java. The sematics of xml parsers don't differ too much, it comes down to navigating through the DOM tree.

JDBCSupport - An easy to use, light-weight JDBC framework -
Ulas Ergin
Ranch Hand

Joined: Oct 10, 2002
Posts: 77
see NanoXML,it is a very simple to ise DOM parser.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

It looks like Harshana is looking for a way to generate an XML document - not for parsing an XML document.

You could use the XML stream API for that (see the package, new in Java 6), or you can just do it the simple way by printing the content out:

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

That's not great though. It doesn't handle escaping very well. I'd recommend a third party as well - JDOM.

Alternatively, you can use the Java SE API:
With thanks to Core Java Volume II

How To Ask Questions How To Answer Questions
Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 331
Thank You very much guys for your valuable kind of researching on it these days with what you guys said
I agree. Here's the link:
subject: XML document create with Java
It's not a secret anymore!