This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Generating XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Generating XML" Watch "Generating XML" New topic
Author

Generating XML

Andrew Shepperd
Greenhorn

Joined: Jul 28, 2001
Posts: 1
Using DOM Transform to generate XML. Works OK, but attributes appear in a hard to read end-to-end block. Anyone know if there is a way to get them neatly indented on individual lines?
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Using Xerces

using Crimson
Using the Sun's Crimson you can cast the w3c document to type of XmlDocument and then use the write method.

This method works except for a small shortcoming - every save creates a carriage return character behind every closing tag. As I open modify and then save the same file these characters are adding up quickly.

Using Transformer Package that is included with JAXP1.1

This method works great except for one major flaw. If your document had a DOCTYPE, when you load your document, add some nodes etc.. and then save, you will notice the DOCTYPE declaration missing!!.
HTH
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
 
 
subject: Generating XML
 
Similar Threads
How to pass XML String to EJB
This weeks giveaway XML@Whiz
Typo mistake in SCWCD Study Kit Book?
XML v JSP
erro web.xml