Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pretty printing XML

 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone seen code that will pretty print my XML? Something with less over-head than a real parser? Thanks.
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
One of the IBM DOM tutorial says that
System.out.println(root.toString()); will print the XML in a non-normalized way,its also say that you may not see the output pretty printed due to version conflict,you can give a try with ur java version.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really?
And 'root' is the xml string? Or a DOM thing? (I am new to DOM/SAX)
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tutorial(understanding DOM) is at DOM tutorial,you can good intro to DOM there.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That tutorial was very helpful.
But the print out is giving me [<the doc root>: null] which isn't even ugly.
A note on one of the pages says: "If the application does not print out the structure of the root element, check the CLASSPATH. The JAXP jar files must appear first if other XML implementations are also present. If you are using Java 2 SDK version 1.4, the output may look "pretty printed"."
I am not running 1.4, do you know what they mean by JAXP?
My code:
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Related thread
I tried lots of different solutions, not all of them I am sure, but I ended up writing my own. It is a basic state engine, no tree or anything like that. It handles attributes and subscripts.

[ October 08, 2002: Message edited by: William Barnes ]
[ October 08, 2002: Message edited by: William Barnes ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic