I've been spending hours trying to figure this out... why isn't this working to parse this: http://developer.trulia.com/docs/LocationInfo/getNeighborhoodsInCity <?php // Construct the GetPriceResearch REST call $apicall = "http://api.trulia.com/webservices.php?library=LocationInfo&function= getNeighborhoodsInCity&city=Seattle&state=WA&apikey=MY_KEY"; // Load the call and capture the XML document returned by API $xml = file_get_contents($apicall); // Check to see if the XML response was loaded, else print an error if ($xml) { $results = ''; if( $xml->Errors ) { // If there was an error in the response, print a warning. $results = "Uh oh, there was an error making the query!"; } else { // Gather our statistics $LocationInfo = $xml->LocationInfo; $city = $LocationInfo->city; $state = $LocationInfo->state; $neighborhood = $LocationInfo->neighborhood['name']; $results .= "<b>city:</b> $city<br/>"; $results .= "<b>state:</b> $state<br/>"; $results .= "<b>neighborhood:</b> $neighborhood<br/>"; } } // If there was no XML response, print an error else { $results = "Dang! Must not have got the XML response!"; } ?> PHP:
I would try debugging the situation: first parse the XML, and then try print_r($var) to see what the variable looks like. Posting that here would help me.
file_get_contents() doesn't return an object. I guess you're looking for something like simplexml_load_file().
rcadble, you've been alot of help to me... unfortunately I don't know how to do what you stated above. nico_swd, I tried simplexml_load_file($api_call); & it didnt work for me