XML_RSS

XML_RSS --  Parsing RSS files with PHP.

Synopsis

require_once "XML/RSS.php";

Introduction to RSS

Resource Description Framework (RDF) Site Summary (RSS) documents are XML documents, that provide a lightweight multipurpose extensible metadata description and syndication format. RSS files are often used to syndicate news or headlines from portal sites (e.g. Slashdot or freshmeat.net).

For more information on RSS see the website of the RSS working group (http://www.purl.org/rss/).

Usage Example

The following script fetches the latest headlines from Slashdot.org via RSS.

XML_RSS::XML_RSS

void XML_RSS::XML_RSS (mixed handle)

This function is the constructor for the RSS parser. It takes on argument, $handle. This parameter defines the resource, where the RSS data is reachable. It can be either a string that represents an URL or a local filename or it can be a file handle to an already opened file.

XML_RSS::parse

boolean XML_RSS::parse ()

This function has to be called in order to parse the content of the RSS file that has been loaded via XML_RSS:XML_RSS ().

XML_RSS::getStructure

array XML_RSS::getStructure ()

This function returns an array containing all elements of the RSS file in the same order, than they were ordered in the original file.

Beispiel 3. Output of getStructure() with the above example RSS file:

Array
(
    [0] => Array
        (
            [type] => channel
            [title] => FooBar Inc.
            [link] => http://example.com/
            [description] => abcd, xyz, 123
        )

    [1] => Array
        (
            [type] => image
            [title] => FooBar
            [url] => http://example.com/images/rssicon.gif
            [link] => http://example.com/
        )

    [2] => Array
        (
            [type] => item
            [title] => Headline 1
            [link] => http://example.com/news.php?h=1
        )

    [3] => Array
        (
            [type] => item
            [title] => Headline 2
            [link] => http://example.com/news.php?h=2
        )

    [4] => Array
        (
            [type] => textinput
            [title] => Search FooBar Inc.
            [description] => Search FooBar Inc. headlines
            [name] => q
            [link] => http://example.com/search.php
        )

)

XML_RSS::getChannelInfo

array XML_RSS::getChannelInfo ()

This function returns an array containing the information that has been extracted from the <channel>-tag while parsing the RSS file.

XML_RSS::getItems

array XML_RSS::getItems ()

This function returns an array containing the set of items that are provided by the RSS file.

XML_RSS::getImages

array XML_RSS::getImages ()

This function returns an array containing the set of images that are provided by the RSS file.

XML_RSS::getTextinputs

array XML_RSS::getTextinputs ()

This function returns an array containing the set of text input fields that are provided by the RSS file.