title: "String could not be parsed as XML" php error
body: <p>I keep getting this error when I try to create a new instance of <code>SimpleXMLElement</code>.</p>
  
  <p>I checked my xml syntax manually and with online tools, and even copy/pasted the example XML file from <a href="http://php.net" rel="nofollow">php.net</a>, but I’m still getting the error.</p>
  
  <p>My code:</p>
  
  <pre><code>include 'example.php';
  $namevalues= new SimpleXMLElement($xmlstr);
  </code></pre>
  
  <p>The example.php:</p>
  
  <pre><code>&lt;?php
  $xmlstr = &lt;&lt;&lt;XML
  &lt;?xml version='1.0' standalone='yes'?&gt;
  &lt;movies&gt;
   &lt;movie&gt;
    &lt;title&gt;PHP: Behind the Parser&lt;/title&gt;
    &lt;characters&gt;
     &lt;character&gt;
      &lt;name&gt;Ms. Coder&lt;/name&gt;
      &lt;actor&gt;Onlivia Actora&lt;/actor&gt;
     &lt;/character&gt;
     &lt;character&gt;
      &lt;name&gt;Mr. Coder&lt;/name&gt;
      &lt;actor&gt;El Act&amp;#211;r&lt;/actor&gt;
     &lt;/character&gt;
    &lt;/characters&gt;
    &lt;plot&gt;
     So, this language. It's like, a programming language. Or is it a
     scripting language? All is revealed in this thrilling horror spoof
     of a documentary.
    &lt;/plot&gt;
    &lt;great-lines&gt;
     &lt;line&gt;PHP solves all my web problems&lt;/line&gt;
    &lt;/great-lines&gt;
    &lt;rating type="thumbs"&gt;7&lt;/rating&gt;
    &lt;rating type="stars"&gt;5&lt;/rating&gt;
   &lt;/movie&gt;
  &lt;/movies&gt;
  XML;
  ?&gt;
  </code></pre>
  
  <p>The error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'Exception' with message 'String could
    not be parsed as XML' in
    C:\AbyssRoot\htdocs\Forum\Sources\showhomework.php on line 266</p>
  </blockquote>