XML pretty printer

J

jmm-list-gn

Hello,
Most XML examples have the content neatly laid out with newlines and
indenting. A DOM parser, however, does not bother with such niceties when
creating an XML file.
Is there a "pretty printer" function somewhere that makes XML easier to
read by adding the indenting?
 
P

Patrick TJ McPhee

% Is there a "pretty printer" function somewhere that makes XML easier to
% read by adding the indenting?

xmllint from the libxml distribution has a --format option which might
do what you want. http://xmlsoft.org
 
J

Johnny Kent

jmm-list-gn said:
Hello,
Most XML examples have the content neatly laid out with newlines and
indenting. A DOM parser, however, does not bother with such niceties when
creating an XML file.
Is there a "pretty printer" function somewhere that makes XML easier to
read by adding the indenting?

Not sure how you are reading the XML.
Most browsers will render XML all pretty like you want. The XML itself
doesn't care about the formatting so it's really up to the viewer you use. A
simple text editor will not do what you want as I'm sure you've found.
Here's a similar discussion
http://tinyurl.com/68zkg
OTOH you could use XSLT to transform your XML to the format you want....
 
J

jmm-list-gn

Patrick said:
% Is there a "pretty printer" function somewhere that makes XML easier to
% read by adding the indenting?

xmllint from the libxml distribution has a --format option which might
do what you want. http://xmlsoft.org
Yes, that is exactly it. Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top