$zip = $_REQUEST['zipID'];
$url = 'http://www.zillow.com/webservice/GetDemographics.htm?zws-id=X1-ZWz1c2hu5r9fd7_5f91a&zip=';
$fullUrl = $url.$zip;
This basically provides a XML output that I used to grab the data. Below is the output from the query.
Once I had the data I then grabbed the Zip code returned as well as all of the attribute tags and its child tags. I did this withe the following code.
$zip = $xml->xpath('/Demographics:demographics/response/region/zip/text()');
$attr = $xml->xpath('//attribute');
Once I had all of the attribute tags into the array I was able to access them by using a for loop in order to iterate through all of them and return them back to the Javascript code and finally to the users browser.
for($i=0; $i<10;>name
echo $attr[$i]->values->zip->value[0]
echo $attr[$i]->values->nation->value[0]
}
You can see that the Xpath methods use a object type of structure to access the child nodes. The -> denotes a child node and once you know the path you can traverse all of the tags. For instance the query echo $attr[$i]->values->zip->value[0] is used to access the following data:
Once you have grabbed all of the data you can simply use a series of echos from the PHP script to send the data to the Javascript in a nicely formated string.
Anyway, the final output looks like this. I is not to fancy but it provides the data necessary.
I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you! hausverwalter duisburg
ReplyDelete