Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have got basically two options here, for easy of use I assign the item to a variable of its own first:</p> <pre><code>$item = $items[$i]; </code></pre> <p>And then the two options for debugging:</p> <pre><code>var_dump($item); echo $item-&gt;asXML(); </code></pre> <p>The first line will create a <code>var_dump</code>, which is PHP and in this case even SimpleXML specific:</p> <pre><code>class SimpleXMLElement#193 (5) { public $title =&gt; string(29) "Asylum seeker system overload" public $link =&gt; string(29) "http://www.abc.net.au/bestof/" public $description =&gt; class SimpleXMLElement#287 (0) { } public $pubDate =&gt; string(31) "Thu, 22 Nov 2012 00:00:00 +1100" public $guid =&gt; string(8) "s3638457" } </code></pre> <p>The second line will create something I bet is common to you, the XML itself:</p> <pre><code>&lt;item&gt; &lt;title&gt;Asylum seeker system overload&lt;/title&gt; &lt;link&gt;http://www.abc.net.au/bestof/&lt;/link&gt; &lt;description&gt;&lt;![CDATA[ &lt;img style="float:right;" src="http://www.abc.net.au/common/images/news_asylum125.jpg" alt="Asylum seeker detainees (ABC News)"&gt; &lt;p&gt;The Australian government is preparing to allow thousands of asylum seekers to love in the community.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://mpegmedia.abc.net.au/news/lateline/video/201211/LATc_FedNauru_2111_512k.mp4"&gt;Watch (4:23)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.abc.net.au/lateline/content/2012/s3638174.htm"&gt;More - Lateline&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; ]]&gt;&lt;/description&gt; &lt;pubDate&gt;Thu, 22 Nov 2012 00:00:00 +1100&lt;/pubDate&gt; &lt;guid isPermaLink="false"&gt;s3638457&lt;/guid&gt; &lt;/item&gt; </code></pre> <p>You did not see any output with:</p> <pre><code>echo $items[$i]; </code></pre> <p>because that <code>&lt;item&gt;</code> element does not have a value, but just subelements. For example</p> <pre><code>echo $items[$i]-&gt;title; </code></pre> <p>Will output the string:</p> <pre><code>Asylum seeker system overload </code></pre> <p>I hope this is helpful and sheds some light. You find the <a href="http://codepad.viper-7.com/DPsAVp" rel="nofollow">demo here</a>, it also shows that you can make use of <code>foreach</code>:</p> <pre><code>$i = 0; foreach ($rss-&gt;channel-&gt;item as $item) { if ($i++ == 2) { var_dump($item); echo $item-&gt;asXML(), "\n", $item-&gt;title; } } </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.
 

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