mtorbin Posted August 4, 2009 Share Posted August 4, 2009 Hey all, I'm probably missing something super easy, but for whatever reason, my simpleXML object call is coming back null. Here is my code: <?php class VenueData { public function __construct($key,$name) { $this->searchURL = 'http://ws.audioscrobbler.com/2.0/?method=venue.search&api_key=' . $key . '&limit=1&venue=' . $name; $this->searchXML = simplexml_load_file($this->searchURL); $this->venueMatches = $this->searchXML->venuematches->{venue}; print(gettype($this->venueMatches) . "\n"); } } ?> Without giving away my key, here is a url that you can use to see the xml that's being pulled back: http://ws.audioscrobbler.com/2.0/?method=venue.search&api_key=b25b959554ed76058ac220b7b2e0a026&venue=arena Please help me figure out what I'm missing here. Thanks, - MT Quote Link to comment Share on other sites More sharing options...
mtorbin Posted August 4, 2009 Author Share Posted August 4, 2009 Ah, got it! I didn't go up high enough on the chain: <?php class VenueData { public function __construct($key,$name) { $searchURL = 'http://ws.audioscrobbler.com/2.0/?method=venue.search&api_key=' . $key . '&limit=1&venue=' . $name; $searchXML = simplexml_load_file($searchURL); foreach($searchXML->results->venuematches->venue as $venue) { print($venue->id . "\n"); } } } ?> - MT Quote Link to comment 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.