Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use simplexml extension functions to achieve your goals. With this extension you can load xml from <a href="http://www.php.net/manual/en/function.simplexml-load-file.php" rel="nofollow">file</a>, from <a href="http://www.php.net/manual/en/function.simplexml-load-string.php" rel="nofollow">string</a> or from a <a href="http://www.php.net/manual/en/function.simplexml-import-dom.php" rel="nofollow">html node</a>. Follow the links to get more information about each load function. I will explain here how to load using simplexml_load_file. This code:</p> <pre><code>&lt;?php echo "&lt;pre&gt;"; $xml = simplexml_load_file("name.xml"); print_r($xml); echo "&lt;/pre&gt;"; ?&gt; </code></pre> <p>Will return this:</p> <pre><code>SimpleXMLElement Object ( [@attributes] =&gt; Array ( [count] =&gt; [time] =&gt; 0.011766910552979 ) [item] =&gt; Array ( [0] =&gt; SimpleXMLElement Object ( [id] =&gt; 607 [name] =&gt; MSPOT6071 [description] =&gt; Hip Hop / Raps [type] =&gt; 3 [radio_folder_id] =&gt; SimpleXMLElement Object ( ) [albumart] =&gt; http://cdn.7static.com/static/img/sleeveart/00/009/560/0000956027_175.jpg [albumart_300] =&gt; http://cdn.7static.com/static/img/sleeveart/00/009/560/0000956027_350.jpg [albumart_500] =&gt; http://cdn.7static.com/static/img/sleeveart/00/009/560/0000956027_500.jpg ) [1] =&gt; SimpleXMLElement Object ( [id] =&gt; 48542614 [name] =&gt; US Pop - TESTB [description] =&gt; Blues [type] =&gt; 3 [radio_folder_id] =&gt; SimpleXMLElement Object ( ) ) ) ) </code></pre> <p>The information you want, can be accessed like this:</p> <pre><code>&lt;?php echo "&lt;pre&gt;"; $xml = simplexml_load_file("name.xml"); print_r($xml); echo "&lt;/pre&gt;"; echo "&lt;pre&gt;"; foreach($xml-&gt;children() as $item){ $arr = get_object_vars($item); foreach($arr as $key=&gt;$value){ echo "$key =&gt; $value" . PHP_EOL; } } echo "&lt;/pre&gt;"; ?&gt; </code></pre> <p>Note it will be accessed as object first. Then you can get all object vars to dynamically navigate through your object attributes.</p>
    singulars
    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. 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