Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create XML document in Java

Status
Not open for further replies.

dellyjm

Programmer
Apr 13, 2000
168
JM
Does anyone know how to create an XML Document in Java?

Thanks.

Delton.
 
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();

Hope that helps
-pete
 
You may need to use a third party package such as XALAN or XERCES or JDOM.

The package javax.xml.parsers only contains interfaces and factories that handle third XML Parser implementations. This is so that you can write generic code... you will need to download one of the above, read about it and try to understand it before you even begin to think of using javax.xml.*.

You can get JDOM from - u will need the jar file in your classpath somewhere.

Typically in JDOM you would create a XML Document by doing this:

...
org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
org.jdom.Document document = builder.build(new File(location.getFile()));

...


good luck :)


matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top