Title: MagpieRSS::__construct
Published: August 18, 2015
Last modified: May 20, 2026

---

# MagpieRSS::__construct( $source )

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/magpierss/__construct/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/magpierss/__construct/?output_format=md#related)

[ Back to top](https://developer.wordpress.org/reference/classes/magpierss/__construct/?output_format=md#wp--skip-link--target)

PHP5 constructor.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/magpierss/__construct/?output_format=md#source)󠁿

    ```php
    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_element_handler($this->parser,
    			array( $this, 'feed_start_element' ), array( $this, 'feed_end_element' ) );

    	xml_set_character_data_handler( $this->parser, array( $this, '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 );
    		}
    	}

    	if ( PHP_VERSION_ID < 80000 ) { // xml_parser_free() has no effect as of PHP 8.0.
    		xml_parser_free( $this->parser );
    	}

    	unset( $this->parser );

    	$this->normalize();
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rss.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rss.php#L61)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rss.php#L61-L103)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/magpierss/__construct/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_trigger_error()](https://developer.wordpress.org/reference/functions/wp_trigger_error/)`wp-includes/functions.php` |

Generates a user-level error/warning/notice/deprecation message.

  | 
| [MagpieRSS::error()](https://developer.wordpress.org/reference/classes/magpierss/error/)`wp-includes/rss.php` |  | 
| [MagpieRSS::normalize()](https://developer.wordpress.org/reference/classes/magpierss/normalize/)`wp-includes/rss.php` |  |

| Used by | Description | 
| [MagpieRSS::MagpieRSS()](https://developer.wordpress.org/reference/classes/magpierss/magpierss/)`wp-includes/rss.php` |

PHP4 constructor.

  | 
| [_response_to_rss()](https://developer.wordpress.org/reference/functions/_response_to_rss/)`wp-includes/rss.php` |

Retrieve

  |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fmagpierss%2F__construct%2F)
before being able to contribute a note or feedback.