0

Ive got an RSS parser using the DOM. Its got a loop to display each item. I want to have a hidden field on each item then post this to another page.

Im having trouble counting each item in the loop. Help please :)

This is what ive got:

<?php
function get_remotetitle($urlpage)
	{
	$dom = new DOMDocument();

	        if($dom->loadHTMLFile($urlpage)) {

	            $list = $dom->getElementsByTagName("title");
	            if ($list->length > 0) {
	                return $list->item(0)->textContent;
	            }
	        }
	}
	
$links = array('feed1','feed2');

foreach($links as $link){
	
$doc = new DOMDocument();
$doc->load($link);
 
$dataset = $doc->getElementsByTagName( "item" );

foreach( $dataset as $row )
{
 
    $xmlEmails = $row->getElementsByTagName( "link" );
    $xmlEmail = $xmlEmails->item(0)->nodeValue;
	$title = get_remotetitle($xmlEmails->item(0)->nodeValue);
 

    echo '<a href="'.$xmlEmail.'">'.$title.'</a><br />';
	echo '<input type="hidden" name="loopnum" value="loopnum">';
}
}

	
?>
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by pritaeas
0
$loopnum = 0;
foreach( $dataset as $row ) {
  $xmlEmails = $row->getElementsByTagName( "link" );
  $xmlEmail = $xmlEmails->item(0)->nodeValue;
  $title = get_remotetitle($xmlEmails->item(0)->nodeValue);
  echo '<a href="'.$xmlEmail.'">'.$title.'</a><br />';
  echo "<input type=\"hidden\" name=\"loopnum\" value=\"$loopnum\">";
  $loopnum++;
}
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.