core/model/modx/xmlrss/magpierss.class.php
Constants
RSS
= 'RSS'
Project: MagpieRSS: a simple RSS integration tool File: rss_parse.inc - parse an RSS or Atom feed return as a simple object.
Handles RSS 0.9x, RSS 2.0, RSS 1.0, and Atom 0.3
The lastest version of MagpieRSS can be obtained from: http://magpierss.sourceforge.net
For questions, help, comments, discussion, etc., please join the Magpie mailing list: [email protected]
- Author
- Kellan Elliott-McCrea
- License
- GPL
- Version
- 0.7a
Functions
array_change_key_case(
$array, $case
=
CASE_LOWER
)
:
void
Name | Type | Description |
---|---|---|
$array | ||
$case |
\MagpieRSS
Hybrid parser, and object, takes RSS as a string and returns a simple object.
see: magpierss.class.php for a simpler interface with integrated caching support
Properties
$_CONTENT_CONSTRUCTS= 'array('content', 'summary', 'info', 'title', 'tagline', 'copyright')'
array('content', 'summary', 'info', 'title', 'tagline', 'copyright')
Details- Type
- n/a
$_KNOWN_ENCODINGS= 'array('UTF-8', 'US-ASCII', 'ISO-8859-1')'
array('UTF-8', 'US-ASCII', 'ISO-8859-1')
Details- Type
- n/a
Methods
__construct(
$source, string $output_encoding
=
'ISO-8859-1', string $input_encoding
=
null, bool $detect_encoding
=
true
)
:
void
Set up XML parser, parse source, and return populated RSS object..
@param 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
Name | Type | Description |
---|---|---|
$source | ||
$output_encoding | string | 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. |
$input_encoding | string | the character set of the incoming RSS source. Leave blank and Magpie will try to figure it out. |
$detect_encoding | bool | if false Magpie won't attempt to detect source encoding. (caveat emptor) |
create_parser(
$source, $out_enc, $in_enc, $detect
)
:
void
return XML parser, and possibly re-encoded source
Name | Type | Description |
---|---|---|
$source | ||
$out_enc | ||
$in_enc | ||
$detect |
feed_start_element(
$p, $element, $attrs
)
:
void
Name | Type | Description |
---|---|---|
$p | ||
$element | ||
$attrs |
php4_create_parser(
$source, $in_enc, $detect
)
:
void
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
Name | Type | Description |
---|---|---|
$source | ||
$in_enc | ||
$detect |
- See
- \http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss