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

Source for file serializeWithDtd.php

Documentation is available at serializeWithDtd.php

  1. <?PHP
  2. /**
  3.  * This example shows how to add a DocType Declaration to the XML document
  4.  *
  5.  * @author Stephan Schmidt <schst@php.net>
  6.  */
  7.  
  8.     require_once 'XML/Serializer.php';
  9.  
  10.     $options = array(
  11.                         "indent"     => "    ",
  12.                         "linebreak"  => "\n",
  13.                         "addDecl"    => true,
  14.                         "addDoctype" => true,
  15.                         "doctype"    => array(
  16.                                                 'uri' => 'http://pear.php.net/dtd/package-1.0',
  17.                                                 'id' => '-//PHP//PEAR/DTD PACKAGE 0.1'
  18.                                              )
  19.                     );
  20.     
  21.     $serializer = new XML_Serializer($options);
  22.  
  23.     $foo    =   PEAR::raiseError("Just a test"1234);    
  24.     
  25.     $result $serializer->serialize($foo);
  26.     
  27.     if$result === true {
  28.         echo    "<pre>";
  29.         echo    htmlentities($serializer->getSerializedData());
  30.         echo    "</pre>";
  31.     }
  32. ?>

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