Logo Search packages:      
Sourcecode: magpierss version File versions  Download package

MagpieRSS::MagpieRSS ( source,
output_encoding = 'ISO-8859-1',
input_encoding = null,
detect_encoding = true 
)

Set up XML parser, parse source, and return populated RSS object..

Parameters:
string$sourcestring containing the RSS to be parsed

NOTE: Probably a good idea to leave the encoding options alone unless you know what you're doing as PHP's character set support is a little weird.

NOTE: A lot of this is unnecessary but harmless with PHP5

Parameters:
string$output_encodingoutput the parsed RSS in this character set defaults to ISO-8859-1 as this is PHP's default.

NOTE: might be changed to UTF-8 in future versions.

Parameters:
string$input_encodingthe character set of the incoming RSS source. Leave blank and Magpie will try to figure it out.
bool$detect_encodingif false Magpie won't attempt to detect source encoding. (caveat emptor)

Definition at line 94 of file rss_parse.inc.

References create_parser().

    {   
        # if PHP xml isn't compiled in, die
        #
        if (!function_exists('xml_parser_create')) {
            $this->error( "Failed to load PHP's XML Extension. " . 
                          "http://www.php.net/manual/en/ref.xml.php",
                           E_USER_ERROR );
        }
        
        list($parser, $source) = $this->create_parser($source, 
                $output_encoding, $input_encoding, $detect_encoding);
        
        
        if (!is_resource($parser)) {
            $this->error( "Failed to create an instance of PHP's XML parser. " .
                          "http://www.php.net/manual/en/ref.xml.php",
                          E_USER_ERROR );
        }

        
        $this->parser = $parser;
        
        # pass in parser, and a reference to this object
        # setup handlers
        #
        xml_set_object( $this->parser, $this );
        xml_set_element_handler($this->parser, 
                'feed_start_element', 'feed_end_element' );
                        
        xml_set_character_data_handler( $this->parser, 'feed_cdata' ); 
    
        $status = xml_parse( $this->parser, $source );
        
        if (! $status ) {
            $errorcode = xml_get_error_code( $this->parser );
            if ( $errorcode != XML_ERROR_NONE ) {
                $xml_error = xml_error_string( $errorcode );
                $error_line = xml_get_current_line_number($this->parser);
                $error_col = xml_get_current_column_number($this->parser);
                $errormsg = "$xml_error at line $error_line, column $error_col";

                $this->error( $errormsg );
            }
        }
        
        xml_parser_free( $this->parser );

        $this->normalize();
    }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index