XML parsing of new lines on PHP4 and PHP5

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

    #1

    XML parsing of new lines on PHP4 and PHP5

    Say I have the following script:

    <?php
    $contents="<p>t est\ntest</p>";

    $xml_parser = xml_parser_crea te('UTF-8'); // try xml_parser_crea te_ns,
    too.
    xml_set_charact er_data_handler ($xml_parser,'h andler');
    xml_parse($xml_ parser, $contents);

    function handler($parser , $data)
    {
    static $count=1;
    echo "$count. $data<br />";
    $count++;
    }
    ?>

    When ran on PHP4 (via the web, so new lines are seen as spaces) I get
    this:

    1. test
    2.
    3. test

    When ran on PHP5 (via the web) I get this:

    1. test test

    Why the difference? Is there any way to get PHP5 to simulate PHP4's
    behavior?

Working...