php and XML range into array

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-05-05T16:47:44Z Indexed on 2010/05/05 16:58 UTC
Read the original article Hit count: 180

Filed under:
|
|

The code below helps be to get the WHOLE XML and put it into an array. What I'm wondering is, what would be a good way to get the XML only from item 3 - 6 or any arbitrary range instead of the whole document.

 $mt_arr = array();
 $d = new DOMDocument();
 $d->load('http://news.google.com/?output=rss');
 foreach ($d->getElementsByTagName('item') as $t) {
  $list = array ( 'title' => $t->getElementsByTagName('title')->item(0)->nodeValue);
  array_push($mt_arr, $list);
 }

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml