Edit report at https://bugs.php.net/bug.php?id=55279&edit=1
ID: 55279 Updated by: rricha...@php.net Reported by: mathieu at webberig dot be Summary: SimpleXml removes line breaks -Status: Assigned +Status: Not a bug Type: Bug Package: SimpleXML related Operating System: Windows PHP Version: 5.3.6 Assigned To: rrichards Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Attribute values are normalized: http://www.w3.org/TR/REC-xml/#AVNormalize Previous Comments: ------------------------------------------------------------------------ [2011-07-25 06:27:06] paj...@php.net 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 :) ------------------------------------------------------------------------ [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