...

View Full Version : xmlDoc help, looping through and displaying all items?



LJackson
04-06-2009, 07:29 PM
Hi,

i am having trouble with the following code, i would like to find out how many items are in the feed and display certain data from all the items but i am having trouble getting the number of items.

any ideas?


$xml=("http://www.kernow-connect.com/feeds/play.xml");


$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);

//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('prod')->item($i);

$channel_title =
mysql_real_escape_string($channel->getElementsByTagName('name')->item(0)->childNodes->item(0)->nodeValue);

$channel_image =
mysql_real_escape_string($channel->getElementsByTagName('mImage')->item(0)->childNodes->item(0)->nodeValue);

$channel_link =
mysql_real_escape_string($channel->getElementsByTagName('awTrack')->item(0)->childNodes->item(0)->nodeValue);

$channel_promo =
mysql_real_escape_string($channel->getElementsByTagName('promo')->item(0)->childNodes->item(0)->nodeValue);

$channel_id =
mysql_real_escape_string($channel->getElementsByTagName('pId')->item(0)->childNodes->item(0)->nodeValue);

$channel_cost =
mysql_real_escape_string($channel->getElementsByTagName('buynow')->item(0)->childNodes->item(0)->nodeValue);

echo ("<a href='$channel_link'>".$channel_title."</a>");
echo("<br />");
echo $channel_promo;
echo("<br />");
echo $channel_id;
echo("<br />");
echo $channel_cost;
echo("<br />");
echo ("<img src='$channel_image'>");
echo("<br />");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum