Detailed description and usage:
See this example:
$rss=new RSS_parser();
$rss->rss_parse("http://www.phpclasses.org/browse.html/latest/latest.xml");
$ch=$rss->get_channel_data();
$ch_im=$rss->get_channel_image_data();
$ch_ti=$rss->get_channel_textinput_data();
$items=$rss->get_items_data();
The rssdump example shows how to use the information returned by the methods, the structures returned by the get methods are:
- $ch: channel data: an asoc array with channel information (if present)
- $ch_im: channel image data: an asoc array with channel image information (if present)
- $ch_ti: channel textinput data: an asoc array with channel textinput information (if present)
- $items: An array of asociative arrays containing items information (if present)
Documentation
Classes
RSS_parser
Extends: None
Description: A class based on an RDF parser to parse RSS feeds, it can parse any valid RSS feed and return all the informationcontained in the RSS document.
rss_parse
Boolean rss_parse(string $rss)
- This parses an RSS document from a URL or a file storing the information in the object's data members. Accesory functions are provided to retrieve the parsed data.
-
- Parameters:
-
$rss - URL or file name for the RSS document to be parsed
- Returns:
- True if the feed was parsed succesfully, false if there was an error.
- Throws:
None
get_channel_data
Asoc Array get_channel_data(string $rss)
- This returns information about the channel described in the RSS feed, it returns an asociative array with the information present in the feed about the channel. For example link, description, image, textinput.
-
- Parameters:
-
- Returns:
- An asociative array where each key describe a channelproperty if present in the RSS feed.
- Throws:
None
get_channel_image_data
Asoc Array get_channel_image_data(string $rss)
- This returns an asociative array containing information about the channel image. For example link, title and url
-
- Parameters:
-
- Returns:
- An asociative array where each key describes a channel image property.
- Throws:
None
get_channel_textinput_data
Asoc Array get_channel_textinput_data(string $rss)
- Tihs method returns information about the channel's textinput element if present in the RSS feed. It returns an asociative array where each key describes a property of the textinput element, for example: description, link, name, title.
-
- Parameters:
-
- Returns:
- An asociative array where each key describes a channel's texinput property if present.
- Throws:
None
get_items_data
Array get_items_data(string $rss)
- This method returns an array of items. Each member of the array is an asociative array describing an item. For each item properties present in the RSS feed are detailed, for example: title, link, description
-
- Parameters:
-
- Returns:
- An array of asociative arrays.
Typical way to parse it:
foreach($items as $item) {
print("An item:
");
foreach($item as $key=>$val) {
print("$key: $val ");
}
} - Throws:
None
|