Minify an xml in one line

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Minify an xml in one line


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"?>

What I would like to have is the 2 lines (or even 1 line):
<?xml version="1.0" encoding="utf-8" standalone="yes"?>

Any idea is welcome


Jérôme Despatis
[hidden email]