title: SimpleXML with decoded entities
body: <p>How can I make SimpleXML to replace HTML/XML entities with their respective characters, in PHP?</p>
  
  <p>Assume having this XML document, in a string:</p>
  
  <pre><code>$data = '&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;&lt;example&gt;Tom &amp;amp; Jerry&lt;/example&gt;'
  </code></pre>
  
  <p>Obviously, I want SimpleXml to decode <code>&amp;amp;</code> to <code>&amp;</code>. It does not do it by default. I have tried these two ways, neither of which worked:</p>
  
  <pre><code>$xml = new SimpleXMLElement($data);
  $xml = new SimpleXMLElement($data, LIBXML_NOENT);
  </code></pre>
  
  <p>What's the best way to get XML entities decoded? I guess XML parser should do it, I would like to avoid running <code>html_entity_decode</code> before parsing (actually, it won't work either). May this be a problem with the encoding of the string? If so, how could I track and fix it?</p>