ankhmor Posted October 31, 2010 Share Posted October 31, 2010 I'm having trouble loading this kind of KML with PHP http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#RetrievingFeatures example <atom:entry xmlns='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005'> <atom:id> http://maps.google.com/maps/feeds/features/userID/mapID/full/featureID</atom:id> <atom:published>2008-08-14T17:46:06.462Z</atom:published> <atom:updated>2008-08-14T18:12:31.589Z</atom:updated> <atom:category scheme='http://schemas.google.com/g/2005#kind' ..... it seems like the column in atom:entry, etc is causing this. $response = simplexml_load_string($response); print_r($response); the above just gives an empty SimpleXMLElement Object() Any ideas Quote Link to comment https://forums.phpfreaks.com/topic/217392-php-google-maps-and-kml/ Share on other sites More sharing options...
salathe Posted November 1, 2010 Share Posted November 1, 2010 Using print_r or var_dump on a SimpleXML object won't be very helpful. If you want to see the XML, for example to make sure it was loaded, use $response->asXML(). For what it's worth, if the XML string could not be parsed for any reason then simplexml_load_string would return FALSE and one or more E_WARNINGS would have been printed with the specific problem. Quote Link to comment https://forums.phpfreaks.com/topic/217392-php-google-maps-and-kml/#findComment-1128790 Share on other sites More sharing options...
ankhmor Posted November 1, 2010 Author Share Posted November 1, 2010 ok it does load but how do i read it? i mean $response->atom:entry->id or $response->entry->id doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/217392-php-google-maps-and-kml/#findComment-1128795 Share on other sites More sharing options...
salathe Posted November 1, 2010 Share Posted November 1, 2010 Have a read through the basic SimpleXML examples section of the PHP manual. Pay particular attention to example #3, and the short paragraph above it. Quote Link to comment https://forums.phpfreaks.com/topic/217392-php-google-maps-and-kml/#findComment-1128797 Share on other sites More sharing options...
ankhmor Posted November 1, 2010 Author Share Posted November 1, 2010 Ok So I've researched a bit and now I understand namespaces, but I still cannot access the <coordinate></coordinate> can someone please write an simplexml path of how to get the coordinates? http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#RetrievingFeatures <atom:content type='application/vnd.google-earth.kml+xml'> <Placemark xmlns="http://www.opengis.net/kml/2.2"> <name>East River Line</name> <description> <![CDATA[A streetcar proposal for New York's Brooklyn and Queens waterfront]]> </description> <Style> <LineStyle> <color>73FF0000</color> <width>5</width> </LineStyle> </Style> <LineString> <tessellate>1</tessellate> <coordinates>-73.872446,40.774481,0.0 ... -74.005537,40.671329,0.0</coordinates> </LineString> </Placemark> </atom:content> Quote Link to comment https://forums.phpfreaks.com/topic/217392-php-google-maps-and-kml/#findComment-1128819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.