Jump to content


PHP and XML via http source

  • Please log in to reply
2 replies to this topic

#1 tsiedsma

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 09 March 2006 - 09:51 PM

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.

#2 willpower

  • Members
  • PipPipPip
  • Advanced Member
  • 296 posts
  • LocationWarrington, Cheshire, UK

Posted 10 March 2006 - 10:31 PM


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


Wait...I've got it...Bollocks, it's gone again!

If at first you don't succeed....stop using ASP and get onto PHP

#3 txmedic03

  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 11 March 2006 - 01:10 AM

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.


I can't stop you from doing something silly, but at least I can help you do it right.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users