ishboo Posted June 24, 2007 Share Posted June 24, 2007 So I have this xml parser that works fine and my xml file has this: <wpt lat="39.6512" lon="-84.147733"> <time>2006-01-24T00:00:00.0000000-08:00</time> <name>GCZF70</name> The part in my parser that sets where to look in the structure is: $xml_name_key = "*GPX*WPT*NAME"; When I use the above setting, it works correctly so I know the program works, but how would I get the lat and lon values from the <wpt> tag? I tried *GPX*WPT*LAT also *GPX*WPT:lat *GPX*WPT *GPX*WPT-lat none of them worked, how should I code it properly? Quote Link to comment Share on other sites More sharing options...
chigley Posted June 24, 2007 Share Posted June 24, 2007 <?php $string = "<wpt lat=\"39.6512\" lon=\"-84.147733\">\n <time>2006-01-24T00:00:00.0000000-08:00</time>\n <name>GCZF70</name>"; preg_match("/lat=\"([\d.]+)/", $string, $matches); list($full, $lat) = $matches; preg_match("/lon=\"([\d.-]+)\"/", $string, $matches); list($full, $lon) = $matches; unset($full); echo "Lat: {$lat}<br />\nLon: {$lon}"; ?> Try that, untested. Quote Link to comment Share on other sites More sharing options...
ishboo Posted June 24, 2007 Author Share Posted June 24, 2007 Thank you, the code worked but that requires me to get the file contents of the xml, can I still get that information using php xml parsing tools? Quote Link to comment 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.