title: Issue with parsing some elements out of a KML file
body: <p>I have an issue with trying to parse out bits of data using PHP from a KML file that I have generated and then sent to my webserver. I want to get the elements out, and store them to a database. Storing them isn't an issue, its just getting some elements out.</p>
  
  <p>Here is en example of the KML file im trying to parse:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;
      &lt;Document&gt;
          &lt;name&gt;RandomName&lt;/name&gt;
          &lt;description&gt;-&lt;/description&gt;
          &lt;Style id="line"&gt;
              &lt;LineStyle&gt;
              &lt;color&gt;CD0000FF&lt;/color&gt;
              &lt;width&gt;4&lt;/width&gt;
              &lt;/LineStyle&gt;
          &lt;/Style&gt;
          &lt;ExtendedData&gt;
              &lt;Data name="StartTime"&gt;
                  &lt;value&gt;1302653118875&lt;/value&gt;
              &lt;/Data&gt;
              &lt;Data name="EndTime"&gt;
                  &lt;value&gt;1302653159274&lt;/value&gt;
              &lt;/Data&gt;
              &lt;Data name="Type"&gt;
                  &lt;value&gt;cycle&lt;/value&gt;
              &lt;/Data&gt;
          &lt;/ExtendedData&gt;
  
      &lt;Placemark&gt;
          &lt;name&gt;PlaceName2&lt;/name&gt;
          &lt;description&gt;&lt;p&gt;Current Altitude: &lt;b&gt;0.0 ft&lt;/b&gt;&lt;br/&gt;Current Speed: &lt;b&gt;0.0 m/s&lt;/b&gt;&lt;br/&gt;Total Distance: &lt;b&gt;0.608 km&lt;/b&gt;&lt;/p&gt;&lt;/description&gt;
          &lt;styleUrl&gt;#line&lt;/styleUrl&gt;
          &lt;LineString&gt;
              &lt;extrude&gt;1&lt;/extrude&gt;
              &lt;tessellate&gt;1&lt;/tessellate&gt;
              &lt;coordinates&gt;
              -122.083393,37.427768,0.0
              -122.084395,37.427768,0.0
              &lt;/coordinates&gt;
          &lt;/LineString&gt;
      &lt;/Placemark&gt;
  &lt;/Document&gt;
  &lt;/kml&gt;
  </code></pre>
  
  <p>I am using the following code, and I am able to get out the very first name and description.</p>
  
  <pre><code>function getTrackDescription($file){
      $xml = simplexml_load_file($file);
      $namespace = $xml-&gt;getDocNamespaces();
  
      if(isset($namespace[""])){
          $xml-&gt;registerXPathNamespace("default",$namespace[""]);
      }
  
      $element= $xml-&gt;xpath('//default:description');
      return $element[0];
  }
  </code></pre>
  
  <p>I am able to get these elements but when I attempt to get anything else, I just get nothing. I need to be able to access the values within ExtendedData - StartTime, EndTime and Type. I also need to get the description from Placemark.</p>
  
  <p>I changed 1 line from the above code, in attempting to get the StartTime, but it doesn't work.</p>
  
  <pre><code>$element= $xml-&gt;xpath('//default:ExtendedData/Data[name="StartTime"]/value');
  </code></pre>
  
  <p>If anyone could help me out, or point me in the right direction I would be really greatful as I haven't really used XML to much.</p>
  
  <p>Thank you.</p>