I've seen various threads on this matter but none have been able to help me. Basically, I'm interpreting a KML file with the intent of loading it in to a map but the namespaces are really screwing me up. Here's an example of the KML:
<?xml version="1.0" encoding="UTF-8">
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:atom="http://www.w3.org/2005/Atom">
<Folder>
<name>leeds primary schools (1 - 10)</name>
<open>1<open>
<Placemark>
blah blah blah
</Placemark>
[etc etc etc]
So the idea is that I want to get all the Placemark elements on the page. So I'm using this code:
$xml = simplexml_load_string($xml_string);
$xml->registerXPathNamespace("n", "http://www.opengis.net/kml/2.2");
$Placemarks = $xml->xpath("/n:Placemark");
And yet, I'm getting diddly-squit out, just an empty array. Can anyone see anything I'm doing wrong?