Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This was how i have eventually done it using XMLReader:</p> <pre><code>&lt;?php define ('XMLFILE', 'http://ws.audioscrobbler.com/2.0/artist/vasco%20rossi/images.rss'); echo "&lt;pre&gt;"; $items = array (); $i = 0; $xmlReader = new XMLReader(); $xmlReader-&gt;open(XMLFILE, null, LIBXML_NOBLANKS); $isParserActive = false; $simpleNodeTypes = array ("title", "description", "media:title", "link", "author", "pubDate", "guid"); while ($xmlReader-&gt;read ()) { $nodeType = $xmlReader-&gt;nodeType; // Only deal with Beginning/Ending Tags if ($nodeType != XMLReader::ELEMENT &amp;&amp; $nodeType != XMLReader::END_ELEMENT) { continue; } else if ($xmlReader-&gt;name == "item") { if (($nodeType == XMLReader::END_ELEMENT) &amp;&amp; $isParserActive) { $i++; } $isParserActive = ($nodeType != XMLReader::END_ELEMENT); } if (!$isParserActive || $nodeType == XMLReader::END_ELEMENT) { continue; } $name = $xmlReader-&gt;name; if (in_array ($name, $simpleNodeTypes)) { // Skip to the text node $xmlReader-&gt;read (); $items[$i][$name] = $xmlReader-&gt;value; } else if ($name == "media:thumbnail") { $items[$i]['media:thumbnail'] = array ( "url" =&gt; $xmlReader-&gt;getAttribute("url"), "width" =&gt; $xmlReader-&gt;getAttribute("width"), "height" =&gt; $xmlReader-&gt;getAttribute("height"), "type" =&gt; $xmlReader-&gt;getAttribute("type") ); } else if ($name == "media:content") { $items[$i]['media:content'] = array ( "url" =&gt; $xmlReader-&gt;getAttribute("url"), "width" =&gt; $xmlReader-&gt;getAttribute("width"), "height" =&gt; $xmlReader-&gt;getAttribute("height"), "filesize" =&gt; $xmlReader-&gt;getAttribute("fileSize"), "expression" =&gt; $xmlReader-&gt;getAttribute("expression") ); } } print_r($items); echo "&lt;/pre&gt;"; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload