xpath question

From: Date: Wed, 20 Feb 2008 01:13:53 +0000
Subject: xpath question
Groups: php.general 
Request: Send a blank email to php-general+get-269670@lists.php.net to get a copy of this message
Hey guys, I have a form accepting a KML file from users and from there I want to draw polylines based on a KML file's <Placemarker><LineString><coordinates> element. The problem I am having is that sometimes the KML file can have a <document><folder> or <folder><document> or none of the above, or any number of random scenarios in the KML file making it hard to parse. To deal with this randomness I'm using an xpath and I think I have it right but it just wont work... the code: $result = $xml->xpath('Placemark/LineString/coordinates'); An the particular XML file I am trying to pull from looks like: <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.1"> <Document> <name>coehilltotweed.kml</name> <Style id="lineStyle"> <LineStyle> <color>64eeee17</color> <width>6</width> </LineStyle> </Style> <Folder> <name>23-SEP-06</name> <Snippet maxLines="2"> </Snippet> <description><![CDATA[<table> <tr><td><b>Distance</b> 139.0 mi </td></tr> <tr><td><b>Min Alt</b> 451.4 ft </td></tr> <tr><td><b>Max Alt</b> 1168.9 ft </td></tr> </table>]]></description> <Placemark> <name>Path</name> <styleUrl>#lineStyle</styleUrl> <LineString> <tessellate>1</tessellate> <coordinates> -77.827985,44.851878,311.109985 -77.82702000000001,44.852114,313.993896 -77.827213,44.85067600000001,313.513306 -77.827792,44.850955,313.513306 -77.830389,44.85333700000001,315.916504 -77.833114,44.858379,317.358643 -77.83193300000001,44.858508,313.993896 </coordinates> </LineString> </Placemark> </Folder> </Document> </kml> Any ideas why this won't work? Thanks!

« previous php.general (#269670) next »