Connecting Tech Pros Worldwide Help | Site Map

php5, tidy and xml cleaning problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 11:27 AM
Börni
Guest
 
Posts: n/a
Default php5, tidy and xml cleaning problem

Hello,

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");
$tidy->cleanRepair();
// write to the file
file_put_contents($path, (string)$tidy);

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


The End of a long post

Greetings

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.