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.  
  8. require_once 'XML/Unserializer.php';
  9.  
  10. $xml '<dict>
  11.    <word>
  12.      <en>chickenwings</en>
  13.      <de>'.utf8_encode().'</de>
  14.    </word>
  15.  </dict>';
  16.     
  17. // specify different source and target encodings
  18. $options = array(
  19.                   XML_UNSERIALIZER_OPTION_ENCODING_SOURCE => 'UTF-8',
  20.                   XML_UNSERIALIZER_OPTION_ENCODING_TARGET => 'ISO-8859-1'
  21.                 );
  22.  
  23.                 
  24. //  be careful to always use the ampersand in front of the new operator 
  25. $unserializer &new XML_Unserializer($options);
  26.  
  27. // userialize the document
  28. $status $unserializer->unserialize($xml);
  29.  
  30. if (PEAR::isError($status)) {
  31.     echo 'Error: ' $status->getMessage();
  32. else {
  33.     $data $unserializer->getUnserializedData();
  34.     echo '<pre>';
  35.     print_r($data);
  36.     echo '</pre>';
  37. }
  38. ?>

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