cahamilton Posted April 21, 2009 Share Posted April 21, 2009 Can anyone tell me how it is possible to parse the "totalResults" item in and OpenSearch XML document such as this one: http://ws.audioscrobbler.com/2.0/?api_key=c7d55f27a911c6a0f77040f18758fc5a&method=artist.search&artist=ehfdfjfgjvhfgndfobndfhnfdgnhdfh I've been working on it for about 2 hours and I can't seem to figure it out ??? So far I have: <?php $lastFM_url = 'http://ws.audioscrobbler.com/2.0/?api_key=c7d55f27a911c6a0f77040f18758fc5a&method=artist.search&artist='; $lastFM_search_results = $lastFM_url.$artist_query; // read feed into SimpleXML object $lastFM_searchXML = simplexml_load_file($lastFM_search_results); // get summary counts from opensearch: namespace $counts = $lastFM_searchXML->results->children('http://a9.com/-/spec/opensearchrss/1.0/'); $total = $counts->totalResults; ?> Anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/155115-parsing-opensearch-xml-data/ Share on other sites More sharing options...
Maq Posted April 22, 2009 Share Posted April 22, 2009 What exactly are you trying to do? What do you want to extract? You should probably read up on, "XPath". Quote Link to comment https://forums.phpfreaks.com/topic/155115-parsing-opensearch-xml-data/#findComment-816015 Share on other sites More sharing options...
cahamilton Posted April 22, 2009 Author Share Posted April 22, 2009 Taking this feed for example: http://ws.audioscrobbler.com/2.0/?api_key=c7d55f27a911c6a0f77040f18758fc5a&method=artist.search&artist=muse I'm simply trying to extract the <opensearch:totalResults> of the feed. Because of the structure of this feed is different to all others I have worked with (this is an OpenSearch feed), its proving difficult to understand and get the correct syntax for extracting that element of the feed. Quote Link to comment https://forums.phpfreaks.com/topic/155115-parsing-opensearch-xml-data/#findComment-816448 Share on other sites More sharing options...
cahamilton Posted April 23, 2009 Author Share Posted April 23, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/155115-parsing-opensearch-xml-data/#findComment-817213 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.