471,616 Members | 1,315 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

php5, tidy and xml cleaning problem


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

Jul 17 '05 #1
0 3190

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mike Gifford | last post: by
5 posts views Thread by Andrzej Adam Filip | last post: by
2 posts views Thread by Kyndig | last post: by
40 posts views Thread by VK | last post: by
8 posts views Thread by bruce | last post: by
reply views Thread by BG Mahesh | last post: by
reply views Thread by Karl Groves | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.