Jump to content


This topic is now archived and is closed to further replies.


PHP and XML via http source

Recommended Posts

I need a little help. I need to add some code to a form processor. I will be passing these variables:

$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
to this:
$url = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=crappyfiles&street=".$address."&city=".$city."&state=".$state."&zip=".$zip."";
I then need to parse that XML and pull 3 values from the results which looks like this:
<ResultSet xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd">
<Result precision="address">
   <Address>237 N CHEROKEE DR</Address>
   <City>POLK CITY</City>
I need to pull the longitude, latitude and zip code from that generated xml and have it be the following variables:
$lng = longitude
$lat = latitude
$zip = zip

I am a total noob and need help doing this. I know its not that hard for some of you, so if you have a little time I would really appreciate it.

Share this post

Link to post
Share on other sites

This is known (i belive) as a SOAP request and callback.

Basically its a web service where you are sending a reqest to their server and having information passed back to you in the form of the XML

Now...I do the same thing (see my previous posts).

The result is an array and I had to intall NuSOAP .php. Its free to download and sits on your server. This then acts as a soap server/client and allows you to easily pass the data back and too.

The only otrher way is to actually parse the XML and extract the data...but thats very overblown.

Get NuSOAP and do a few searches for SOAP XML PHP

Once its all up their I can help with your code


Share this post

Link to post
Share on other sites
If you don't want to use Will's recommended method, I can help you create a parser script very simply. Let me know if you would like the alternative as it doesn't require loading anything extra to your server to make it work, and it does work quite well.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.