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

Source for file unserializeEncoded.php

Documentation is available at unserializeEncoded.php

  1. <?PHP
  2. /**
  3.  * This example shows how to set a different target encoding
  4.  *
  5.  * @author  Stephan Schmidt <schst@php.net>
  6.  */
  7.     error_reporting(E_ALL);
  8.  
  9.     require_once 'XML/Unserializer.php';
  10.  
  11. $xml '<dict>
  12.    <word>
  13.      <en>chickenwings</en>
  14.      <de>'.utf8_encode().'</de>
  15.    </word>
  16.  </dict>';
  17.     
  18.     // specify different source and target encodings
  19.     $options = array(
  20.                       'encoding'       => 'UTF-8',
  21.                       'targetEncoding' => 'ISO-8859-1'
  22.                     );
  23.     
  24.                     
  25.     //  be careful to always use the ampersand in front of the new operator 
  26.     $unserializer &new XML_Unserializer($options);
  27.  
  28.     // userialize the document
  29.     $status $unserializer->unserialize($xml);
  30.  
  31.     if (PEAR::isError($status)) {
  32.         echo    "Error: " $status->getMessage();
  33.     else {
  34.         $data $unserializer->getUnserializedData();
  35.  
  36.         echo    "<pre>";
  37.         print_r$data );
  38.         echo    "</pre>";
  39.     }
  40. ?>

Documentation generated on Mon, 11 Mar 2019 14:19:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.