tsiedsma Posted March 9, 2006 Share Posted March 9, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/4564-php-and-xml-via-http-source/ Share on other sites More sharing options...
willpower Posted March 10, 2006 Share Posted March 10, 2006 HiThis 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 XMLNow...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 PHPOnce its all up their I can help with your codeWill Quote Link to comment https://forums.phpfreaks.com/topic/4564-php-and-xml-via-http-source/#findComment-16253 Share on other sites More sharing options...
txmedic03 Posted March 11, 2006 Share Posted March 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/4564-php-and-xml-via-http-source/#findComment-16288 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.