Currently I'm reading XML attributes in the following way, this is the feed.php file that is called by the index page.
<?php
for ($start < $end) {
$xml=$_POST['q'];
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$i = $xmlDoc->getElementsByTagNameNS('http://search.yahoo.com/mrss/','thumbnail');
$image = $i->item($start)->getAttribute('url');
echo "<img src='$image'></img>";
$start++;
}
?>
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.