title: PHP simple XML parser not returning data
body: <p><strong>I cannot display data from an XML file using the simple PHP parser. How do I fix it?</strong></p>
  
  <p>I cannot find the problem to this simple task and I am completely stuck.  I am following a w3schools.com tutorial and the code won't display the data. I am using an apache web server on my raspberry pi.</p>
  
  <p>PHP:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;style&gt;
              code {
                  font-family: ;
              } div {
                  margin-top: 5px;
                  margin-bottom: 5px;
                  margin-left: 5px;
                  margin-right: 5px;
                  background-color: rgb(177,177,177);
                  height: 200px;
                  width: 300px;
              }
          &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;center&gt;&lt;h1&gt;Hello BISD! This is a perfectly fine webpage!&lt;/h1&gt;&lt;/center&gt;
          &lt;p&gt;TXT File:&lt;/p&gt;
          &lt;div&gt;
          &lt;?php
          $file=fopen("placeholder.txt","r");
          while(!feof($file)) {
              echo fgets($file).'&lt;br&gt;';
          }
          fclose($file);
          ?&gt;
          &lt;/div&gt;
          &lt;p&gt;XML File:&lt;/p&gt;
          &lt;div&gt;
          &lt;?php
          $XMLFile = simplexml_load_file("test.xml");
          if ($XMLFile === false) {
              echo "Failed loading XML: ";
              foreach(libxml_get_errors() as $error) {
                  echo "&lt;br&gt;", $error-&gt;message;
              }
          } else {
              foreach($XMLFile-&gt;message() as $data) {
                  echo $data-&gt;subject;
                  echo $data-&gt;recipient;
                  echo $data-&gt;sender;
              }
          }
          ?&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;message&gt;
      &lt;subject&gt;Test XML File&lt;/subject&gt;
      &lt;sender&gt;Harry&lt;/sender&gt;
      &lt;recipient&gt;The Internet&lt;/recipient&gt;
      &lt;content&gt;Hello world!&lt;/content&gt;
  &lt;/message&gt;
  &lt;message&gt;
      &lt;subject&gt;Regarding XML&lt;/subject&gt;
      &lt;sender&gt;Harry&lt;/sender&gt;
      &lt;recipient&gt;The Internet&lt;/recipient&gt;
      &lt;content&gt;XML is awesome!&lt;/content&gt;
  &lt;/message&gt;
  </code></pre>
  
  <p>The page loads the txt file and displays it fine.</p>