Jump to content

Recommended Posts

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

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

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.
Link to comment
https://forums.phpfreaks.com/topic/4564-php-and-xml-via-http-source/
Share on other sites

Hi

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

Will

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.