Currently I'm reading XML attributes in the following way, this is the feed.php file that is called by the index page.

for ($start < $end) {
$xmlDoc = new DOMDocument();
$i = $xmlDoc->getElementsByTagNameNS('http://search.yahoo.com/mrss/','thumbnail');
$image = $i->item($start)->getAttribute('url');
echo "<img src='$image'></img>";

Where $start and $end are ints that specify which stories to show from the feed I am reading. How do I cope with it if there are multiple elements with the same name, in my case I would only like to read the second "<media:content...>"'s attributes each time I iterate over an <item> node's children.

This is where I am reading from: view-source:http://feeds.bbci.co.uk/news/rss.xml

Note that I would like my feed to be generalisable so if another URL was to be input, it can be read aswell so I cannot preset variables to increase by 2 for the images or something like that, nor can I hold count of them in the main index.php file for the same reason (to keep it generalisable). Is there a method which would allow me to only read the correct one from each of the <item> elements. The correct one for me is the one with a larger height and width. But please note, because I have set the index page to have a button which when pressed lists more stories, this means I cannot skip certain images in feed.php file since the main count is maintained in the index file which will have no idea of what has been skipped.

Edited by asif49: n/a

5 Years
Discussion Span
Last Post by Ezzaral
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.