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

Source for file unserializeWhitespace.php

Documentation is available at unserializeWhitespace.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 '<xml>
  11.    <string>
  12.    
  13.     This XML
  14.     document
  15.     contains
  16.     line breaks.
  17.  
  18.    </string>
  19.  </xml>';
  20.  
  21.  
  22. //  be careful to always use the ampersand in front of the new operator 
  23. $unserializer &new XML_Unserializer();
  24. $unserializer->setOption(XML_UNSERIALIZER_OPTION_RETURN_RESULTtrue);
  25.  
  26. echo '<pre>';
  27.  
  28. echo "Default behavior (XML_UNSERIALIZER_WHITESPACE_TRIM)\n";
  29. $data $unserializer->unserialize($xml);
  30. var_dump($data);
  31. echo "\n\n";
  32.  
  33. echo "Normalize whitespace (XML_UNSERIALIZER_WHITESPACE_NORMALIZE)\n";
  34. $data $unserializer->unserialize($xml);
  35. var_dump($data);
  36. echo "\n\n";
  37.  
  38. echo "Keep whitespace (XML_UNSERIALIZER_WHITESPACE_KEEP)\n";
  39. $data $unserializer->unserialize($xml);
  40. var_dump($data);
  41.  
  42. echo '</pre>';
  43. ?>

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