title: how to get an array of xml with php?
body: <p>how to get an array of xml with php in this format, of an external file</p>
  
  <pre><code>$locations = array(
    (Bondi Beach, -33.890542, 151.274856, 4),
    (Coogee Beach, -33.923036, 151.259052, 5),
    (Cronulla Beach', -34.028249, 151.157507, 3)
  );
  //this is my file php
           $dom = new DOMDocument();
              $dom-&gt;load('school.xml');
              $students = $dom-&gt;getElementsByTagName('student');
              $i = 0; 
              foreach ($students as $student) {
                  $locations = $students-&gt;item(0)-&gt;nodeValue;
                  echo $locations;
                  $i++;
              }
  </code></pre>
  
  <p>when I run this code returns the following result:<br>
  Bondi Beach -33.890542 151.274856 4 Coogee Beach -33.923036 151.259052 5 Cronulla Beach -34.028249 151.157507 3<br>
  What do I have to change so that It return an array with the following format?:</p>
  
  <p>this is my array school.xml  </p>
  
  <pre><code>&lt;school&gt;
  &lt;student&gt;
  &lt;name&gt;Bondi Beanch&lt;/name&gt;
  &lt;latitude&gt;-33.890542&lt;/latitude&gt;
  &lt;longitude&gt;151.274856&lt;/longitude&gt;
  &lt;id&gt;4&lt;/id&gt;
  &lt;/student&gt;
  &lt;student&gt;
  &lt;name&gt;Coogee Beach&lt;/name&gt;
  &lt;latitude&gt;-33.923036&lt;/latitude&gt;
  &lt;longitude&gt;151.259052&lt;/longitude&gt;
  &lt;id&gt;5&lt;/id&gt;
  &lt;/student&gt;
  &lt;student&gt;
  &lt;name&gt;Cronulla Beach&lt;/name&gt;
  &lt;latitude&gt;-34.028249&lt;/latitude&gt;
  &lt;longitude&gt;151.157507&lt;/longitude&gt;
  &lt;id&gt;3&lt;/id&gt;
  &lt;/student&gt;
  &lt;/school&gt;
  </code></pre>