Jump to content

Parsing OpenSearch XML data?


cahamilton

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/155115-parsing-opensearch-xml-data/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.