|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55279 SimpleXml removes line breaks
Submitted: 2011-07-25 06:17 UTC Modified: 2012-09-20 06:51 UTC
Avg. Score:3.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mathieu at webberig dot be Assigned: rrichards (profile)
Status: Not a bug Package: SimpleXML related
PHP Version: 5.3.6 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
44 + 2 = ?
Subscribe to this entry?

 [2011-07-25 06:17 UTC] mathieu at webberig dot be
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 version="1.0"?>
<feed><entry description="this is the first line
here's a second line
and another!" /></feed>

$xml = simplexml_load_string($xmldata);
foreach ($xml->entry as $entry)
$attributes = $entry->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 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-25 06:27 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: rrichards
 [2011-07-25 06:27 UTC]
As 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 :)
 [2012-09-20 06:51 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Attribute values are normalized:
 [2012-09-20 06:51 UTC]
-Status: Assigned +Status: Not a bug
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 07:01:30 2024 UTC