W3C home > Mailing lists > Public > html-tidy@w3.org > July to September 2011

Minify an xml in one line

From: Jérôme DESPATIS <jerome@despatis.com>
Date: Mon, 22 Aug 2011 21:10:03 +0200
Message-ID: <4E52A98B.9030902@despatis.com>
To: html-tidy@w3.org
Hello,

I have an xml file
I'd like to create the smallest file as I can.
So as a result I'd like that my xml holds on a single line (or 2 lines, 
the <?xml...> being the first line)

Any idea how to do this with tidy ? I haven't found the parameter to 
perform that in tidy.
And another thing, I'd like to avoid post process that removes the \n, 
as my xml may contain CDATA with \n in it, that I have to leave untouched

My config for tidy is:
--------------------------
$config = array('input-xml'  => true,
                         'output-xml' => true,
                         'indent'     => true,
                         'wrap'       => 0);

A minimalistic xml could be:
-----------------------------------
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed>
<title>Title</title>
<id>geofeed-contacts</id>
<entry>
<title>Title</title>
</entry>
</feed>

What I would like to have is the 2 lines (or even 1 line):
----------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed><title>Title</title><id>geofeed-contacts</id><entry><title>Title</title></entry></feed>

Any idea is welcome

Thanks!

-- 
Jérôme Despatis
jerome@despatis.com
Received on Wednesday, 24 August 2011 12:37:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:14:01 GMT