XML_Serializer
[ class tree: XML_Serializer ] [ index: XML_Serializer ] [ all elements ]

Source for file serializeRDF.php

Documentation is available at serializeRDF.php

  1. <?PHP
  2. /**
  3.  * This example shows how to create an RDF document
  4.  * with a few lines of code.
  5.  * This can also be done with mode => simplexml
  6.  *
  7.  * @author Stephan Schmidt <schst@php.net>
  8.  * @see    serializeIndexedArray.php
  9.  */
  10.  
  11.     require_once 'XML/Serializer.php';
  12.  
  13.     $options = array(
  14.                         "indent"         => "    ",
  15.                         "linebreak"      => "\n",
  16.                         "typeHints"      => false,
  17.                         "addDecl"        => true,
  18.                         "encoding"       => "UTF-8",
  19.                         "rootName"       => "rdf:RDF",
  20.                         "rootAttributes" => array("version" => "0.91"),
  21.                         "defaultTagName" => "item"
  22.                     );
  23.     
  24.     $serializer = new XML_Serializer($options);
  25.  
  26.     
  27.     $rdf    =   array(
  28.                         "channel" => array(
  29.                                             "title" => "Example RDF channel",
  30.                                             "link"  => "http://www.php-tools.de",
  31.                                             "image"    =>    array(
  32.                                                                 "title"    => "Example image",
  33.                                                                 "url"    =>    "http://www.php-tools.de/image.gif",
  34.                                                                 "link"    =>    "http://www.php-tools.de"
  35.                                                             ),
  36.                                             array(
  37.                                                 "title"    => "Example item",
  38.                                                 "link"    => "http://example.com"
  39.                                             ),
  40.                                             array(
  41.                                                 "title"    => "Another item",
  42.                                                 "link"    => "http://example.com"
  43.                                             ),
  44.                                             array(
  45.                                                 "title"    => "I think you get it...",
  46.                                                 "link"    => "http://example.com"
  47.                                             )
  48.                                         )
  49.                     );
  50.     
  51.     $result $serializer->serialize($rdf);
  52.     
  53.     if$result === true {
  54.         echo    "<pre>";
  55.         echo    htmlentities($serializer->getSerializedData());
  56.         echo    "</pre>";
  57.     }
  58. ?>

Documentation generated on Mon, 11 Mar 2019 10:15:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.