MagpieRSS::__construct( $source )

In this article

PHP5 constructor.

Source

function __construct( $source ) {

	# Check if PHP xml isn't compiled
	#
	if ( ! function_exists('xml_parser_create') ) {
		wp_trigger_error( '', "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." );
		return;
	}

	$parser = xml_parser_create();

	$this->parser = $parser;

	# pass in parser, and a reference to this object
	# set up 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 );
	unset( $this->parser );

	$this->normalize();
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.