jump to navigation

Format XML documents in linux May 24, 2007

Posted by Mayank in ubuntu.
trackback

To format xml documents in linux you can use a utility called xmllint.


# set the indent
$> export XMLLINT_INDENT=" "

$> xmllint –format –recover <XML_File_name> > <New_file_name>

Advertisements

Comments»

1. adam - July 10, 2009

Just a note that this won’t work on xhtml files with custom tags as it appears xmllint attempts to validate tag names while parsing.

2. adam - July 10, 2009

crap. sorry, i should have said it works fine, but generates errors.

3. orian - September 1, 2011

Hi,
On my version of xmllint (20706) proper command looks:
xmllint –format –recover simple.xml > simple.well_formated.xml

Jasper - January 30, 2013

The text on the blog seems to replace the minus sign (-) with a different character.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: