From:
Operating system: Windows
PHP version: 5.3.6
Package: SimpleXML related
Bug Type: Bug
Bug description:SimpleXml removes line breaks
Description:
------------
SimpleXML seems to ignore/remove line breaks (\n) in the attributes. Line
breaks
inside an attribute are valid XML, but they're lost when you use SimpleXML
to read
the XML data.
I encountered this problem when reading XML data provided by the Google
Webmaster
Tools API
Test script:
---------------
XML:
<?xml version="1.0"?>
<feed><entry description="this is the first line
here's a second line
and another!" /></feed>
PHP:
$xml = simplexml_load_string($xmldata);
foreach ($xml->entry as $entry)
{
$attributes = $entry->attributes();
print_r($attributes);
}
Expected result:
----------------
Keep the line breaks from the attribute values after reading the string.
$attributes['description'] == "this is the first line
here's a second line
and another!";
Actual result:
--------------
The string no longer contains line breaks:
$attributes['description'] == "this is the first line here's a second line
and
another!";
--
Edit bug report at https://bugs.php.net/bug.php?id=55279&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55279&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55279&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55279&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55279&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55279&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55279&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55279&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55279&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55279&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55279&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55279&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55279&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55279&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55279&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55279&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55279&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55279&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55279&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55279&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55279&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55279&r=mysqlcfg