cvs: peardoc /en/package/xml xml-serializer.xml /en/package/xml/xml-serializer intro.xml /en/package/xml/xml-serializer/xml-serializer
tutorial-rss.xml

From: Date: Tue, 04 Mar 2008 07:27:37 +0000
Subject: cvs: peardoc /en/package/xml xml-serializer.xml /en/package/xml/xml-serializer intro.xml /en/package/xml/xml-serializer/xml-serializer
tutorial-rss.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-10553@lists.php.net to get a copy of this message
cweiske Tue Mar 4 07:27:37 2008 UTC Added files: /peardoc/en/package/xml/xml-serializer/xml-serializer tutorial-rss.xml Modified files: /peardoc/en/package/xml xml-serializer.xml /peardoc/en/package/xml/xml-serializer intro.xml Log: fix bug #12725: xml_serializer tuto link no more available

http://cvs.php.net/viewvc.cgi/peardoc/en/package/xml/xml-serializer.xml?r1=1.6&r2=1.7&diff_format=u Index: peardoc/en/package/xml/xml-serializer.xml diff -u peardoc/en/package/xml/xml-serializer.xml:1.6 peardoc/en/package/xml/xml-serializer.xml:1.7 --- peardoc/en/package/xml/xml-serializer.xml:1.6 Thu Jun 1 05:08:07 2006 +++ peardoc/en/package/xml/xml-serializer.xml Tue Mar 4 07:27:37 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <sect1 id="package.xml.xml-serializer"> <title>XML_Serializer</title> &package.xml.xml-serializer.intro; @@ -23,7 +23,7 @@ This classes can be used to serialize any data structure in a way that it can later be unserialized again. XML_Serializer will store the type of the value and additional meta information - in attributes of the surrounding tag. This meta information can later be used + in attributes of the surrounding tag. This meta information can later be used to restore the original data structure in PHP. </para> </listitem> @@ -38,6 +38,8 @@ &package.xml.xml-serializer.xml-serializer.resetoptions; &package.xml.xml-serializer.xml-serializer.setoption; &package.xml.xml-serializer.xml-serializer.examples; + &package.xml.xml-serializer.xml-serializer.tutorial-rss; + <refentry id="package.xml.xml-serializer.xml-unserializer-summary"> <refnamediv> <refname>Class Summary <classname>XML_Unserializer</classname></refname> http://cvs.php.net/viewvc.cgi/peardoc/en/package/xml/xml-serializer/intro.xml?r1=1.5&r2=1.6&diff_format=u Index: peardoc/en/package/xml/xml-serializer/intro.xml diff -u peardoc/en/package/xml/xml-serializer/intro.xml:1.5 peardoc/en/package/xml/xml-serializer/intro.xml:1.6 --- peardoc/en/package/xml/xml-serializer/intro.xml:1.5 Thu Jun 1 05:09:14 2006 +++ peardoc/en/package/xml/xml-serializer/intro.xml Tue Mar 4 07:27:37 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry id="package.xml.xml-serializer.intro"> <refnamediv> <refname>Introduction</refname> @@ -7,10 +7,10 @@ <refsect1 id="package.xml.xml-serializer.intro.refsect1"> <title>Introduction to XML_Serializer</title> <para> - XML_Serializer serializes complex data structures + XML_Serializer serializes complex data structures like arrays or object as XML documents. - - This class helps you generating any XML document + + This class helps you generating any XML document you require without the need for DOM. </para> <para> @@ -18,25 +18,25 @@ <itemizedlist> <listitem> <para> - use XML_Serializer's functionality to create XML documents - in a specific XML application (e.g. RDF) + use XML_Serializer's functionality to create XML documents + in a specific XML application (e.g. RDF) that is being processed by an existing script) </para> </listitem> <listitem> <para> use XML_Serializer's functionality to serialize data structures that have - to be unserialized at a later point. - + to be unserialized at a later point. + This is possible by adding type information to all XML elements. </para> </listitem> </itemizedlist> </para> <para> - The package not only contains a serializer class + The package not only contains a serializer class but also a matching XML_Unserializer, - which is able to virtually read any XML document + which is able to virtually read any XML document and return an array or object structure that represents the data stored in the document. </para> @@ -44,27 +44,31 @@ <refsect1 id="package.xml.xml-serializer.intro.refsect2"> <title>Tutorials on XML_Serializer</title> <para> - There are several tutorials on XML_Serializer available, + There are several tutorials on XML_Serializer available, that help you get started. </para> <para> <itemizedlist> <listitem> <para> - <ulink url="http://www.sitepoint.com/article/xml-php-pear-xml_serializer">Instant XML with PHP and PEAR::XML_Serializer</ulink> - by Harry Fuecks + <link linkend="package.xml.xml-serializer.xml-serializer.tutorial-rss"> + Create a RSS newsfeed with XML_Serializer + </link> (local) + by cnb </para> </listitem> + <listitem> <para> - <ulink url="http://www.melonfire.com/community/columns/trog/article.php?id=244">Serializing XML With PHP</ulink> - by Vikram Vaswani + <ulink url="http://www.sitepoint.com/article/xml-php-pear-xml_serializer">Instant XML with PHP and PEAR::XML_Serializer</ulink> + by Harry Fuecks </para> </listitem> + <listitem> <para> - <ulink url="http://freedomink.org/node/62">Create a RSS newsfeed with XML_Serializer</ulink> - by cnb + <ulink url="http://www.melonfire.com/community/columns/trog/article.php?id=244">Serializing XML With PHP</ulink> + by Vikram Vaswani </para> </listitem> </itemizedlist> @@ -89,5 +93,5 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 ---> +--> http://cvs.php.net/viewvc.cgi/peardoc/en/package/xml/xml-serializer/xml-serializer/tutorial-rss.xml?view=markup&rev=1.1 Index: peardoc/en/package/xml/xml-serializer/xml-serializer/tutorial-rss.xml +++ peardoc/en/package/xml/xml-serializer/xml-serializer/tutorial-rss.xml <!-- $Revision: 1.1 $ --> <!-- $Author: cweiske $ --> <refentry id="package.xml.xml-serializer.xml-serializer.tutorial-rss"> <refnamediv> <refname>Tutorial: Create an RSS Feed</refname> <refpurpose>How to use XML_Serializer to build an RSS Newsfeed</refpurpose> </refnamediv> <refsect1 id="package.xml.xml-serializer.xml-serializer.tutorial-rss.mission"> <title>Mission</title> <note> <para> This tutorial has been written by cnb and been published on <ulink url="http://freedomink.org/node/62">http://freedomink.org/node/62</ulink>. The site is offline since 2005 and has been rescued using the Internet Archive's Wayback Machine. </para> </note> <para> Here's how you can create an XML news feed in just five minutes using PHP, PEAR and the PEAR XML_Serializer package by Stephan Schmidt. </para> <para> What a news feed consists of in it's barest form is your "site name", "site url" and a "listing of stories" from your site. To create a news feed what we need to do is create a publically accessible (web) document which can show this information in a format other sites can understand. This is possible by creating this document in the standard RDF Site Summary (RSS) format. A format used by many sites. </para> <para> What we are aiming at is creating a document which looks like the following: </para> <note> <para> This isn't "well formed" XML but a stripped version making it as simple as possible for illustrative purposes. Once we understand the basics we can move on to create well formed XML. </para> </note> <programlisting role="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <rdf:RDF> <channel> <title>Freedom Ink</title> <link>http://freedomink.org/</link> <item> <item> <title>First Article</title> <link>http://freedomink.org/node/view/55</link> <description>Short blurb about article........</description> </item> <item> <title>Second Article</title> <link>http://freedomink.org/node/view/11</link> <description>This article shows you how ......</description> </item> </item> </channel> </rdf:RDF>]]></programlisting> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-serializer.tutorial-rss.inphp"> <title>Do it in PHP</title> <para> Here's an easy way to do it in PHP. </para> <para> Prerequisite: Install PEAR and the <classname>XML_Serializer</classname> package. </para> <para> Include the following default options at the top of your php page. </para> <programlisting role="php"><![CDATA[<?php require_once 'XML/Serializer.php'; $options = array( "indent" => " ", "linebreak" => "\n", "typeHints" => false, "addDecl" => true, "encoding" => "UTF-8", "tagName" => "rdf:RDF", "defaultTagName" => "item" ); ?>]]></programlisting> <para> Let us first create an array containing a listing of the stories on your site. </para> <para> We create array <varname>$stories</varname> and add one story. </para> <programlisting role="php"><![CDATA[ $stories[] = array( 'title' => 'First Article', 'link' => 'http://freedomink.org/node/view/55', 'description' => 'Short blurb about article........' );]]></programlisting> <para> You can add more stories to the array in the same manner. Ideally this should be done in a "for" or "foreach" loop. </para> <programlisting role="php"><![CDATA[ $stories[] = array( 'title' => 'Second Article', 'link' => 'http://freedomink.org/node/view/11', 'description' => 'This article shows you how ......' );]]></programlisting> <para> Finally we specify the channel details and add the stories to it. </para> <programlisting role="php"><![CDATA[ $data['channel'] = array( "title" => "Freedom Ink", "link" => "http://freedomink.org/", $stories );]]></programlisting> <para> Now we generate the XML using the PEAR <classname>XML_Serializer</classname> package. </para> <programlisting role="php"><![CDATA[ $serializer = new XML_Serializer($options); if ($serializer->serialize($data)) { header('Content-type: text/xml'); echo $serializer->getSerializedData(); } ]]></programlisting> <para> And that's it! When a person visits the page containing this code an XML file like the one we saw above will be generated and served. </para> <para> To learn how to parse XML/RSS files you can read this related article which has by far the easiest method of parsing XML/RSS documents. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.pear.doc (#10553) next »