Hi all, I'm launching new jobs site - Environmental Jobs In USA. As you can see at the right side of the side I want to add news, there are any scripts so I can add RSS of news sites and that will be shown at my site. It's php based. Thanks for the helpers...
Cobano, if you want to find free scripts that can do this I am pretty sure hotscripts might have something your looking for.
here it is ... <?php $xml_parser = xml_parser_create(); // Set the functions to handle opening and closing tags xml_set_element_handler($xml_parser, "startElement", "endElement"); // Set the function to handle blocks of character data xml_set_character_data_handler($xml_parser, "characterData"); // Open the XML file for reading $fp = fopen("http://www.sitepoint.com/rss.php","r") or die("Error reading RSS data."); // Read the XML file 4KB at a time while ($data = fread($fp, 4096)) // Parse each 4KB chunk with the XML parser created above xml_parse($xml_parser, $data, feof($fp)) // Handle errors in parsing or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); // Close the XML file fclose($fp); // Free up memory used by the XML parser xml_parser_free($xml_parser); ?>
sorry use this one...... <?php class RSSParser { var $insideitem = false; var $tag = ""; var $title = ""; var $description = ""; var $link = ""; function startElement($parser, $tagName, $attrs) { if ($this->insideitem) { $this->tag = $tagName; } elseif ($tagName == "ITEM") { $this->insideitem = true; } } function endElement($parser, $tagName) { if ($tagName == "ITEM") { printf("\"<dt><b><a href='%s'>%s</a></b></dt>",trim($this->link),trim($this->title)); printf("<b>%s</b>",trim($this->description)); $this->title = ""; $this->description = ""; $this->link = ""; $this->insideitem = false; } } function characterData($parser, $data) { if ($this->insideitem) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "LINK": $this->link .= $data; break; } } } } $xml_parser = xml_parser_create(); $rss_parser = new RSSParser(); xml_set_object($xml_parser,&$rss_parser); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); $fp = fopen("http://www.thedailystar.net/latest/rss/rss.xml","r") or die("Error reading RSS data."); while ($data = fread($fp, 4096)) xml_parse($xml_parser, $data, feof($fp)) or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); fclose($fp); xml_parser_free($xml_parser); ?>
please change this line : printf("\"<dt><b><a href='%s'>%s</a></b></dt>",trim($this->link),trim($this->title)); to printf("<dt><b><a href='%s'>%s</a></b></dt>",trim($this->link),trim($this->title));