Forum Moderators: open

Message Too Old, No Replies

Quick XML/PHP Question

         

rjbearcan

4:45 am on Oct 25, 2007 (gmt 0)

10+ Year Member



Well I am sure it will be quick anyway. I am making a quick local event mashup and I have been using Google's geocoder to plot the locations but it doesn't get everything and Yahoo catches other results. Their xml returns as such:

<Result precision="address">
<Latitude></Latitude>
<Longitude></Longitude>
<Address></Address>
<City></City>
<State></State>
<Zip></Zip>
<Country></Country>
</Result>

I want to loop through the geocoder to catch only those with an address precision (others include street, zip, city, state). I tried:
$xml = new SimpleXMLElement($url);
$xml1 = $xml->Result->precision="Address";
but obviously that didn't work. Any help would be appreciated!

cmarshall

10:28 am on Oct 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Howdy. I do almost exactly the same thing. If you want, I can SM you a link to the site, so you can see how it operates (I'm not allowed to link it on the public forum).

However, I use XSLT to produce JSON code, which I fetch in an AJAX callback. I don't do the direct XML parsing that you do. XML->XSLT->JSON works quite well for me. It's basically a direct route between the XML and the JavaScript.

If you know how to use SourceForge Subversion [sourceforge.net], I can direct you to a project that contains these scripts, and that runs them from PHP.