Class MagpieRSS

Description

Hybrid parser, and object, takes RSS as a string and returns a simple object.

see: rss_fetch.inc for a simpler interface with integrated caching support

Located in /net/nemein/rss/magpierss/rss_parse.inc (line 35)


	
			
Variable Summary
Method Summary
 MagpieRSS MagpieRSS (string $source, [string $output_encoding = 'ISO-8859-1'], [string $input_encoding = null], [bool $detect_encoding = true])
 void append (mixed $el, mixed $text)
 void append_content (mixed $text)
 void concat (mixed &$str1, [mixed $str2 = ""])
 void create_parser (mixed $source, mixed $out_enc, mixed $in_enc, mixed $detect)
 void error (mixed $errormsg, [mixed $lvl = E_USER_WARNING])
 void feed_cdata (mixed $p, mixed $text)
 void feed_end_element (mixed $p, mixed $el)
 void feed_start_element (mixed $p, mixed $element, mixed &$attrs)
 void is_atom ()
 void is_rss ()
 void known_encoding (mixed $enc)
 void normalize ()
 void php4_create_parser (mixed $source, mixed $in_enc, mixed $detect)
 void php5_create_parser (mixed $in_enc, mixed $detect)
Variables
mixed $channel = array() (line 40)
mixed $current_field = '' (line 64)
mixed $current_item = array() (line 38)
mixed $current_namespace = false (line 65)
mixed $encoding = '' (line 45)
mixed $ERROR = "" (line 49)
mixed $feed_type (line 43)
mixed $feed_version (line 44)
mixed $image = array() (line 42)
mixed $inchannel = false (line 59)
mixed $incontent = false (line 61)
mixed $inimage = false (line 63)
mixed $initem = false (line 60)
mixed $intextinput = false (line 62)
mixed $items = array() (line 39)
mixed $parser (line 36)
mixed $stack = array() (line 58)
mixed $textinput = array() (line 41)
mixed $WARNING = "" (line 50)
mixed $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright') (line 54)
mixed $_KNOWN_ENCODINGS = array('UTF-8', 'US-ASCII', 'ISO-8859-1') (line 55)
mixed $_source_encoding = '' (line 47)
Methods
Constructor MagpieRSS (line 96)

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

MagpieRSS MagpieRSS (string $source, [string $output_encoding = 'ISO-8859-1'], [string $input_encoding = null], [bool $detect_encoding = true])
  • string $source:

    string 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

  • string $output_encoding:

    output 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.

  • string $input_encoding: the character set of the incoming RSS source. Leave blank and Magpie will try to figure it out.
  • bool $detect_encoding: if false Magpie won't attempt to detect source encoding. (caveat emptor)
append (line 338)
void append (mixed $el, mixed $text)
append_content (line 328)
void append_content (mixed $text)
concat (line 319)
void concat (mixed &$str1, [mixed $str2 = ""])
create_parser (line 454)

return XML parser, and possibly re-encoded source

void create_parser (mixed $source, mixed $out_enc, mixed $in_enc, mixed $detect)
error (line 562)
void error (mixed $errormsg, [mixed $lvl = E_USER_WARNING])
feed_cdata (line 262)
void feed_cdata (mixed $p, mixed $text)
feed_end_element (line 274)
void feed_end_element (mixed $p, mixed $el)
feed_start_element (line 148)
void feed_start_element (mixed $p, mixed $element, mixed &$attrs)
is_atom (line 441)
void is_atom ()
is_rss (line 432)
void is_rss ()
known_encoding (line 552)
void known_encoding (mixed $enc)
normalize (line 382)
void normalize ()
php4_create_parser (line 503)

Instaniate an XML parser under PHP4

Unfortunately PHP4's support for character encodings and especially XML and character encodings sucks. As long as the documents you parse only contain characters from the ISO-8859-1 character set (a superset of ASCII, and a subset of UTF-8) you're fine. However once you step out of that comfy little world things get mad, bad, and dangerous to know.

The following code is based on SJM's work with FoF

void php4_create_parser (mixed $source, mixed $in_enc, mixed $detect)
php5_create_parser (line 478)

Instantiate an XML parser under PHP5

PHP5 will do a fine job of detecting input encoding if passed an empty string as the encoding.

All hail libxml2!

void php5_create_parser (mixed $in_enc, mixed $detect)

Documentation generated on Mon, 21 Nov 2005 18:21:41 +0100 by phpDocumentor 1.3.0RC3