Bug #55279 [Opn->Asn]: SimpleXml removes line breaks
| From: | pajoye@php.net | Date: | Mon, 25 Jul 2011 10:27:06 +0000 |
| Subject: | Bug #55279 [Opn->Asn]: SimpleXml removes line breaks | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162155@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55279&edit=1
ID: 55279
Updated by: pajoye@php.net
Reported by: mathieu at webberig dot be
Summary: SimpleXml removes line breaks
-Status: Open
+Status: Assigned
Type: Bug
Package: SimpleXML related
Operating System: Windows
PHP Version: 5.3.6
-Assigned To:
+Assigned To: rrichards
Block user comment: N
Private report: N
New Comment:
As http://www.w3.org/TR/REC-xml/#NT-AttValue
says than new lines are valid in
attribute values, it seems that almost no parser returns them.
This is certainly a problem in libxml itself as simplexml does not transform the
values returned by libxml.
Assigne to Rob so he can check with the libxml devs, whether we like to change
that or not :)
Previous Comments:
------------------------------------------------------------------------
[2011-07-25 06:17:55] mathieu at webberig dot be
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 this bug report at https://bugs.php.net/bug.php?id=55279&edit=1