preserving white space with DOMDocument / loadHTML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yawnmoth

    preserving white space with DOMDocument / loadHTML

    First, here's my code:

    <?php
    $xml = new DOMDocument();
    $xml->preserveWhiteS pace = true;

    $xml->loadXML('
    <html>
    <head/>
    <body/>
    </html>
    ');

    $node = $xml->documentElemen t->getElementsByT agName('body')->item(0);
    $node->parentNode->removeChild($n ode);

    echo $xml->saveHTML();
    ?>

    Any ideas as to why that doesn't preserve the whitespace? When I
    change saveHTML to saveXML, it works just fine...
Working...