title: PHP SimpleXML doesn't preserve line breaks in XML attributes
body: <p>I have to parse externally provided XML that has attributes with line breaks in them.  Using SimpleXML, the line breaks seem to be lost.  According to <a href="https://stackoverflow.com/questions/449627/are-line-breaks-in-xml-attribute-values-valid">another stackoverflow question</a>, line breaks should be valid (even though far less than ideal!) for XML.</p>
  
  <p>Why are they lost?  [edit] <strong>And how can I preserve them?</strong> [/edit]</p>
  
  <p>Here is a demo file script (note that when the line breaks are not in an attribute they are preserved).</p>
  
  <p><strong>PHP File with embedded XML</strong></p>
  
  <pre><code>$xml = &lt;&lt;&lt;XML
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Rows&gt;
      &lt;data Title='Data Title' Remarks='First line of the row.
  Followed by the second line.
  Even a third!' /&gt;
      &lt;data Title='Full Title' Remarks='None really'&gt;First line of the row.
  Followed by the second line.
  Even a third!&lt;/data&gt;
  &lt;/Rows&gt;
  XML;
  
  $xml = new SimpleXMLElement( $xml );
  print '&lt;pre&gt;'; print_r($xml); print '&lt;/pre&gt;';
  </code></pre>
  
  <p><strong>Output from print_r</strong></p>
  
  <pre><code>SimpleXMLElement Object
  (
      [data] =&gt; Array
          (
              [0] =&gt; SimpleXMLElement Object
                  (
                      [@attributes] =&gt; Array
                          (
                              [Title] =&gt; Data Title
                              [Remarks] =&gt; First line of the row. Followed by the second line. Even a third!
                          )
  
                  )
  
              [1] =&gt; First line of the row.
  Followed by the second line.
  Even a third!
          )
  
  )
  </code></pre>