Web Analytics Made Easy -
StatCounter xmlDoc help, looping through and displaying all items? - CodingForum

Announcement

Collapse
No announcement yet.

xmlDoc help, looping through and displaying all items?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • xmlDoc help, looping through and displaying all items?

    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?

    PHP Code:
     $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 />"); 
Working...
X