cvs: peardoc /en/packages xml.xml /en/packages/xml xml_rss.xml
| From: | Martin Jansen | Date: | Fri, 11 Jan 2002 16:58:26 +0000 |
| Subject: | cvs: peardoc /en/packages xml.xml /en/packages/xml xml_rss.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1909@lists.php.net to get a copy of this message | ||
mj Fri Jan 11 11:58:26 2002 EDT
Added files:
/peardoc/en/packages xml.xml
/peardoc/en/packages/xml xml_rss.xml
Log:
* Documentation for XML_RSS.
Index: peardoc/en/packages/xml.xml
+++ peardoc/en/packages/xml.xml
<reference id="packages.xml">
<title>XML</title>
<partintro>
<para>
XML utilities.
</para>
</partintro>
&packages.xml.xml-rss;
</reference>
Index: peardoc/en/packages/xml/xml_rss.xml
+++ peardoc/en/packages/xml/xml_rss.xml
<refentry id="packages.XML.XML_RSS">
<refnamediv>
<refname><classname>XML_RSS</classname></refname>
<refpurpose>
Parsing RSS files with PHP.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>require_once "XML/RSS.php";</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Introduction to RSS</title>
<para>
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).
</para>
<para>
For more information on RSS see the website of the RSS working
group (<ulink url="http://www.purl.org/rss/">
http://www.purl.org/rss/</ulink>).
</para>
<example id="packages.XML.XML_RSS.example_rss">
<title>RSS file</title>
<programlisting role="xml">
<![CDATA[
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://my.netscape.com/rdf/simple/0.9/">
<channel>
<title>FooBar Inc.</title>
<link>http://example.com/</link>
<description>abcd, xyz, 123</description>
</channel>
<image>
<title>FooBar</title>
<url>http://example.com/images/rssicon.gif</url>
<link>http://example.com/</link>
</image>
<item>
<title>Headline 1</title>
<link>http://example.com/news.php?h=1</link>
</item>
<item>
<title>Headline 2</title>
<link>http://example.com/news.php?h=2</link>
</item>
<textinput>
<title>Search FooBar Inc.</title>
<description>Search FooBar Inc. headlines</description>
<name>q</name>
<link>http://example.com/search.php</link>
</textinput>
</rdf:RDF>
]]>
</programlisting>
</example>
</refsect1>
<refsect1>
<title>Usage Example</title>
<simpara>
The following script fetches the latest headlines from
Slashdot.org via RSS.
</simpara>
<example>
<title>Fetching headlines from Slashdot</title>
<programlisting role="php">
<![CDATA[
require_once "XML/RSS.php";
$rss =& new XML_RSS("http://slashdot.org/slashdot.rdf");
$rss->parse();
echo "<h1>Headlines from <a href=\"http://slashdot.org\">Slashdot</a></h1>\n";
echo "<ul>\n";
foreach ($rss->getItems() as $item) {
echo "<li><a href=\"" . $item['link'] .
"\">" . $item['title'] . "</a></li>\n";
}
echo "</ul>\n";
]]>
</programlisting>
</example>
</refsect1>
<refsect1>
<title>XML_RSS::XML_RSS</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>XML_RSS::XML_RSS</function></funcdef>
<paramdef>mixed <parameter>handle</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function is the constructor for the RSS parser. It takes
on argument, <parameter>$handle</parameter>. 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.
</para>
</refsect1>
<refsect1>
<title>XML_RSS::parse</title>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>XML_RSS::parse</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function has to be called in order to parse the content
of the RSS file.
</para>
</refsect1>
<refsect1>
<title>XML_RSS::getStructure</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>XML_RSS::getStructure</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function returns an array containing all elements of the
RSS file in the same order than they were ordered in the original
file.
</para>
<example>
<title>Output of <function>getStructure</function> with the
<link linkend="packages.XML.XML_RSS.example_rss">above</link>
example RSS file:</title>
<programlisting>
<![CDATA[
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
)
)
]]>
</programlisting>
</example>
</refsect1>
<refsect1>
<title>XML_RSS::getChannelInfo</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>XML_RSS::getChannelInfo</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function returns an array containing the information
that has been extracted from the <channel>-tag while parsing
the RSS file.
</para>
</refsect1>
<refsect1>
<title>XML_RSS::getItems</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>XML_RSS::getItems</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function returns an array containing the set of items
that are provided by the RSS file.
</para>
</refsect1>
<refsect1>
<title>XML_RSS::getImages</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>XML_RSS::getImages</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function returns an array containing the set of images
that are provided by the RSS file.
</para>
</refsect1>
<refsect1>
<title>XML_RSS::getTextinputs</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>XML_RSS::getTextinputs</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function returns an array containing the set of text input
fields that are provided by the RSS file.
</para>
</refsect1>
</refentry>