Hey, i have an simpleXMLElement document that features an array of data to do with an artist's albums.
Below is an extract of that XML
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[num] => 3
[type] => artist
)
[title] => DJ Tiësto
[uri] => http://www.discogs.com/artist/DJ+Ti%C3%ABsto
[summary] => DJ Tiësto Tijs Michiel Verwest Dutch trance DJ & producer.
In this XML document there are multiple different types of information from artist info to titles of albums. I want to extract certain parts of this data and echo them out. For instance i want to extract the summary's of the array entries that have the [type] defined to artist. I'm guessing i would use a foreach loop that went through all the entries and checked if this was true? Is this the right way to go about it.
I apologise for my confusing explanation
---- EDIT ----
Heres the PHP code that grabs the data -
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://www.discogs.com/search?type=all&" .
"q=DJ+Tiësto&" .
"f=xml&" .
"api_key=<key>");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_ENCODING, "gzip");
$result = curl_exec($curl);
curl_close($curl);
$xmlmusic = new SimpleXMLElement($result,NULL,true);
foreach ($xmlmusic as $xm)
{
$attrs = $xm->attributes();
if($attrs["type"] == "title")
echo $xm->summary."\n";
}
?>