XML_Serializer::setOption | Tutorial: Create an RSS Feed |
XML_Serializer | |
PEAR Manual | |
Example that uses the returnResult option to directly return the serialized XML document in the serialize() method.
In this example look at theses 3 lines.
|
|
And this is the result
<pear_error> <error_message_prefix /> <mode>1</mode> <level>1024</level> <code>1234</code> <message>Just a test</message> <userinfo /> <backtrace> <XML_Serializer_Tag> <file>pathToMypear\PEAR.php</file> <line>566</line> <function>pear_error</function> <class>pear_error</class> <type>-></type> <args> <XML_Serializer_Tag>Just a test</XML_Serializer_Tag> <XML_Serializer_Tag>1234</XML_Serializer_Tag> <XML_Serializer_Tag>1</XML_Serializer_Tag> <XML_Serializer_Tag>1024</XML_Serializer_Tag> <XML_Serializer_Tag /> </args> </XML_Serializer_Tag> <XML_Serializer_Tag> <file>pathToMyDocRoot\cvs.php.net\pear\xml_serializer\examples\serializeandreturn.php</file> <line>19</line> <function>raiseerror</function> <class>pear</class> <type>::</type> <args> <XML_Serializer_Tag>Just a test</XML_Serializer_Tag> <XML_Serializer_Tag>1234</XML_Serializer_Tag> </args> </XML_Serializer_Tag> </backtrace> <callback /> </pear_error> |
You can find the last version of this source code in the package : serializeAndReturn.php
This example shows how to create an RDF document with a few lines of code. This can also be done with mode => simplexml.
In this example look at theses 3 lines.
|
|
And this is the result
<?xml version="1.0" encoding="UTF-8"?> <rdf:RDF version="0.91"> <channel rdf:about="http://example.com/foobar.html"> <title>Example RDF channel</title> <link xmlns:xlink="http://www.w3.org/1999/xlink">http://www.php-tools.de</link> <image> <title>Example image</title> <url>http://www.php-tools.de/image.gif</url> <link xmlns:xlink="http://www.w3.org/1999/xlink">http://www.php-tools.de</link> </image> <item rdf:about="http://example.com/foobar.html"> <title>Example item</title> <link xmlns:xlink="http://www.w3.org/1999/xlink">http://example.com</link> </item> <item rdf:about="http://example.com/foobar.html"> <title>Another item</title> <link xmlns:xlink="http://www.w3.org/1999/xlink">http://example.com</link> </item> <item rdf:about="http://example.com/foobar.html"> <title>I think you get it...</title> <link xmlns:xlink="http://www.w3.org/1999/xlink">http://example.com</link> </item> </channel> </rdf:RDF> |
You can find the last version of this source code in the package : serializeRDF.php
Note : if you search how to parse (read) an RDF/RSS document, look at XML_RSS package.
This example shows how to add a DocType Declaration to the XML document
In this example look at theses 3 lines.
|
|
And this is the result
<?xml version="1.0"?> <!DOCTYPE pear_error PUBLIC "-//PHP//PEAR/DTD PACKAGE 0.1" "http://pear.php.net/dtd/package-1.0"> <pear_error> <error_message_prefix /> <mode>1</mode> <level>1024</level> <code>1234</code> <message>Just a test</message> <userinfo /> <backtrace> <XML_Serializer_Tag> <file>pathToMyPear\PEAR.php</file> <line>566</line> <function>pear_error</function> <class>pear_error</class> <type>-></type> <args> <XML_Serializer_Tag>Just a test</XML_Serializer_Tag> <XML_Serializer_Tag>1234</XML_Serializer_Tag> <XML_Serializer_Tag>1</XML_Serializer_Tag> <XML_Serializer_Tag>1024</XML_Serializer_Tag> <XML_Serializer_Tag /> </args> </XML_Serializer_Tag> <XML_Serializer_Tag> <file>pathToMyDocumentRoot\cvs.php.net\pear\xml_serializer\examples\serializewithdtd.php</file> <line>24</line> <function>raiseerror</function> <class>pear</class> <type>::</type> <args> <XML_Serializer_Tag>Just a test</XML_Serializer_Tag> <XML_Serializer_Tag>1234</XML_Serializer_Tag> </args> </XML_Serializer_Tag> </backtrace> <callback /> </pear_error> |
You can find the last version of this source code in the package : serializeWithDTD.php
XML_Serializer::setOption | Tutorial: Create an RSS Feed |
XML_Serializer | |
PEAR Manual | |