title: simplexml_load_string and the unwelcome parse error
body: <p><em>Update: Casting as an array does the trick. <a href="https://stackoverflow.com/a/18951415/2605348">See this response</a>, since I don't have enough clout to upvote :)</em></p>
  
  <p>I started on this problem with many potential culprits, but after lots of diagnostics the problem is still there and no obvious answers remain.</p>
  
  <p>I want to print the placename "Gaborone", which is located at the first tag under the first tag under the first tag of this API-loaded XML file. How can I parse this to return that content?</p>
  
  <pre><code>    &lt;?php
  
        # load the XML file
        $test1 = (string)file_get_contents('http://www.afdb.org/fileadmin/uploads/afdb/Documents/Generic-Documents/IATIBotswanaData.xml');
  
        #throw it into simplexml for parsing      
        $xmlfile = simplexml_load_string($test1);
  
        #output the parsed text
        echo $xmlfile-&gt;iati-activity[0]-&gt;location[0]-&gt;gazetteer-entry;
  
      ?&gt;
  </code></pre>
  
  <p>Which never fails to return this:</p>
  
  <pre><code>Parse error: syntax error, unexpected '[', expecting ',' or ';'
  </code></pre>
  
  <p>I've tried changing the syntax to avoid the hyphens in the tag names as such:</p>
  
  <pre><code>echo $xmlfile["iati-activity"][0]["location"][0]["gazetteer-entry"];
  </code></pre>
  
  <p>. . . but that returns complete nothingness; no error, no source.</p>
  
  <p>I've also tried debugging based on <a href="https://stackoverflow.com/questions/14174397/simplexml-load-file-empty-array">these</a> <a href="http://www.phpeveryday.com/articles/SimpleXML-Accessing-Element-P535.html" rel="nofollow noreferrer">otherwise-helpful</a> <a href="https://stackoverflow.com/questions/7894063/simplexml-returns-empty-arrays">threads</a>, but none of the solutions have worked. Is there an obvious error in my simplexml addressing?</p>