saltem8 Posted October 2, 2011 Share Posted October 2, 2011 would anyone be able to tell me how I can limit this script to only pulling in 1 instead of the 10 it currently pulls in, thanks <?php // ###################################################### // ## configuration // ## // ## $rss_file= 'http://www.vbulletin.com/forum/external.php?type=rss'; // ## Adjust this variable to point to your RSS feed $rss_file = 'http://mysite.com/external.php'; // ## configuration end // ###################################################### // ## Do not touch code below! $is_item = false; $tag = ''; $title = ''; $description = ''; $link = ''; function character_data($parser, $data) { global $is_item, $tag, $title, $description, $link; if ($is_item) { switch ($tag) { case "TITLE": $title .= $data; break; case "DESCRIPTION": $description .= $data; break; case "LINK": $link .= $data; break; } } } function begin_element($parser, $name) { global $is_item, $tag; if ($is_item) { $tag = $name; } else if ($name == "ITEM") { $is_item = true; } } function end_element($parser, $name) { global $is_item, $title, $description, $link, $rss_output; if ($name == "ITEM") { $rss_output .= "<dt><strong><a href='" . trim($link) . "'>" . htmlspecialchars(trim($title)) . "</a></strong></dt><dd>" . htmlspecialchars(trim($description)) . "</dd>"; $title = ""; $description = ""; $link = ""; $is_item = false; } } $parser = xml_parser_create(); xml_set_element_handler($parser, "begin_element", "end_element"); xml_set_character_data_handler($parser, "character_data"); $fp = fopen($rss_file,"r"); while ($data = fread($fp, 4096)) { xml_parse($parser, $data, feof($fp)); } fclose($fp); xml_parser_free($parser);?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.