Class MagpieRSS

Description

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

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

Located in /includes/magpierss/rss_parse.php (line 34)


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

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 335)
void append ( $el,  $text)
  • $el
  • $text
append_content (line 325)
void append_content ( $text)
  • $text
concat (line 316)
void concat ( &$str1, [ $str2 = ""])
  • &$str1
  • $str2
create_parser (line 451)

return XML parser, and possibly re-encoded source

void create_parser ( $source,  $out_enc,  $in_enc,  $detect)
  • $source
  • $out_enc
  • $in_enc
  • $detect
error (line 558)
void error ( $errormsg, [ $lvl = E_USER_WARNING])
  • $errormsg
  • $lvl
feed_cdata (line 260)
void feed_cdata ( $p,  $text)
  • $p
  • $text
feed_end_element (line 271)
void feed_end_element ( $p,  $el)
  • $p
  • $el
feed_start_element (line 146)
void feed_start_element ( $p,  $element,  &$attrs)
  • $p
  • $element
  • &$attrs
is_atom (line 438)
void is_atom ()
is_rss (line 429)
void is_rss ()
known_encoding (line 548)
void known_encoding ( $enc)
  • $enc
normalize (line 379)
void normalize ()
php4_create_parser (line 500)

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 ( $source,  $in_enc,  $detect)
  • $source
  • $in_enc
  • $detect
php5_create_parser (line 475)

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 ( $in_enc,  $detect)
  • $in_enc
  • $detect

Documentation generated on Mon, 05 May 2008 16:22:43 +0400 by phpDocumentor 1.4.0