Does anyone know how to get this to display....

Discussion in 'HTML & Website Design' started by fadetoblack22, Apr 1, 2008.

  1. #1
    fadetoblack22, Apr 1, 2008 IP
  2. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,399
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    160
    #2
    no one? surely someone can help?
     
    fadetoblack22, Apr 1, 2008 IP
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your best bet will be to use a server-side programming language to parse the feed into HTML and then serve it with the rest of your page.

    Does your hosting provider support these, such as PHP or .NET?
     
    Dan Schulz, Apr 1, 2008 IP
  4. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,399
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    160
    #4
    yeh, i just don't know how to do it.

    I have this script, but I can't get it to work.

    <?php
    /*
    
    Class RSSParser: 	2 October 2002
    
    Author:				Duncan Gough
    
    Overview:			An RSS parser that uses PHP and freely available RSS feeds to add fresh news content to your site.
    
    Installation:		Decompress the file into your webroot and include it from whichever pages on which you want
    					to display the data, e.g;
    
    					include("rss.php");
    
    Usage:				As above, just include the rss.php file from within your PHP page, and the news will appear.
    					You should find the HTML code in the functions endElement(), show_title() and show_list_box() below,
    					feel free to modify these to match your site.
    */
    
    class RSSParser	{
    
        var $title			= "";
        var $link 			= "";
        var $description 	= false;
        var $inside_item 	= false;
        
    	
    
    	function startElement( $parser, $name, $attrs='' ){
    		global $current_tag;
    
    		$current_tag = $name;
    
    		if( $current_tag == "ITEM" )
    			$this->inside_item = true;
    
    	} // endfunc startElement
    
    	function endElement( $parser, $tagName, $attrs='' ){
    		global $current_tag;
    
        	if ( $tagName == "ITEM" ) {
    
    			printf( "\t<br><b><a href='%s' target='_blank'>%s</a></b>\n", trim( $this->link ), htmlspecialchars( trim( $this->title ) ) );
        		printf( "\t<br>%s<br>\n", htmlspecialchars( trim( $this->description ) ) );
    
        		$this->title = "";
        		$this->description = "";
        		$this->link = "";
        		$this->inside_item = false;
    
        	}
    
    	} // endfunc endElement
    
    	function characterData( $parser, $data ){
    		global $current_tag;
    
    		if( $this->inside_item ){
    			switch($current_tag){
    
    				case "TITLE":
    					$this->title .= $data;
    					break;
    				case "DESCRIPTION":
    					$this->description .= $data;
    					break;
    				case "LINK":
    					$this->link .= $data;
    					break;
    
    				default:
    					break;
    
    			} // endswitch
    
    		} // end if
    
    	} // endfunc characterData
    
    	function parse_results( $xml_parser, $rss_parser, $file )	{
    
    		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("$file","r") or die( "Error reading XML file, $file" );
    
    		while ($data = fread($fp, 4096))	{
    		
    			// parse the data
    			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 ) ) );
    			
    		} // endwhile
    
    		fclose($fp);
    
    		xml_parser_free( $xml_parser );
    
    	} // endfunc parse_results
    
    
    } // endclass RSSParser
    
    global $rss_url;
    
    // Set a default feed
    if( $rss_url == "" )
    	$rss_url = "http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/front_page/rss.xml";
    
    $xml_parser = xml_parser_create();
    $rss_parser = new RSSParser();
    
    $rss_parser->parse_results( $xml_parser, &$rss_parser, $rss_url );
    
    
    ?>
    PHP:
    As you can see it works for the bcc rss.xml feed.
     
    fadetoblack22, Apr 2, 2008 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    fadetoblack22, please check your PM inbox. What I gave you should fix your problem. :)
     
    Dan Schulz, Apr 2, 2008 IP
  6. itliberty

    itliberty Peon

    Messages:
    1,173
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #6
    hopefully dan gave you what you needed. PHP5 added tons of parsing capabilities. And there are better RSS parsers then what you have there...PM me if you dont have what you need.
     
    itliberty, Apr 2, 2008 IP
  7. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's ironic that I gave him a parser as well. But we found out what the problem was. The original RSS feed he was using is a piece of junk.
     
    Dan Schulz, Apr 2, 2008 IP
  8. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    guys i have a feed from a gameing website i would like on my site

    i have tryed in the past but it never worked.. maybee you could pm me some details please.
     
    andymayo, Apr 3, 2008 IP
  9. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Andy, does your server support PHP by any chance?
     
    Dan Schulz, Apr 3, 2008 IP
  10. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #10
    andymayo, Apr 3, 2008 IP
  11. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,399
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    160
    #11
    yeh the rss feed i was using was a piece of junk! i should have checked it first.
     
    fadetoblack22, Apr 6, 2008 IP