php5, tidy and xml cleaning problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I am using tidy to clean up an xml file, but my problem is that it
replaces newlines with normal whitespaces.
Still worse is that if i retrieve text from the xml file it contains all
whitespaces tidy inserted to nicely render the file.
The xml files are generated and retrieved with an DomDocument.
preserveWhitespace is false.

At the time i am solving the problem with some regexps and string
replacements, but this way i have to think of all the weird
possibilities and i am sure i will forget one or two ;-)

So this is how my xml gets saved:

$xml = $dom->saveXML();

// Specify configuration
$config = array(
'indent'        => true,
'input-xml'  => true,
'output-xml'  => true,
'wrap'          => 200);

// Tidy
$tidy = new tidy;
$tidy->parseString($xml, $config, "utf8");
// write to the file
file_put_contents($path, (string)$tidy);

and how i load it:
$dom = new DomDocument();
$dom->preserveWhiteSpace = false;

The End of a long post


Site Timeline