php5, tidy and xml cleaning problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Börni

    #1

    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.
    preserveWhitesp ace 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($x ml, $config, "utf8");
    $tidy->cleanRepair( );
    // write to the file
    file_put_conten ts($path, (string)$tidy);

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


    The End of a long post

    Greetings
Working...