title: simplexml_load_file can't load an XML file
body: <p>I'm trying to do some very basic parsing of XML data but am failing miserably.</p>
  <p>I have a metadata.xml file as such:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
  &lt;metadata&gt;
      &lt;page&gt;
          &lt;filename&gt;products.php&lt;/filename&gt;
          &lt;title&gt;Best selection of products in Anytown, USA&lt;/title&gt;
          &lt;description&gt;We sell quality products&lt;/description&gt;
      &lt;/page&gt;
      &lt;page&gt;
          &lt;filename&gt;services.com&lt;/filename&gt;
          &lt;title&gt;Great services anywhere within Anytown&lt;/title&gt;
          &lt;description&gt;Our services are pretty good&lt;/description&gt;
      &lt;/page&gt;
  &lt;/metadata&gt;
  </code></pre>
  <p>I'm attempting to get a result for a specific XML entry using the code below:</p>
  <pre><code>&lt;?php
      
  $str = simplexml_load_file(&quot;metadata.xml&quot;) or die(&quot;Couldn't load file&quot;);
  
  $data = new SimpleXMLElement($str);
  // Find the element with specific filename
  $nodes = $data-&gt;xpath('//metadata/page/filename[.=&quot;products.php&quot;]/parent::*');
  $result = $nodes[0];
  echo &quot;Title: &quot; . $result-&gt;title . &quot;\n&quot;;
  echo &quot;Description: &quot; . $result-&gt;description . &quot;\n&quot;;
  
  ?&gt;
  </code></pre>
  <p>This results in an error:</p>
  <blockquote>
  <p>Warning: SimpleXMLElement::__construct(): Entity: line 4: parser error : Start tag expected, '&lt;' not found in /var/www/html/php_xml_test.php on line 10</p>
  <p>Fatal error: Uncaught Exception: String could not be parsed as XML in /var/www/html/php_xml_test.php:10 Stack trace: #0 /var/www/html/php_xml_test.php(10): SimpleXMLElement-&gt;__construct('\n\t\n\t\n') #1 {main} thrown in /var/www/html/php_xml_test.php on line 10</p>
  </blockquote>
  <p>If I load the content of the XML file right into the php file everything works fine.</p>
  <p>I've read through a bunch of related posts here but can't figure out where I'm going wrong.</p>
  <p>Thanks!</p>