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

Source for file unserializeWithAttributes.php

Documentation is available at unserializeWithAttributes.php

  1. <?PHP
  2. /**
  3.  * This example shows how to parse attributes from
  4.  * XML tags.
  5.  *
  6.  * @author  Stephan Schmidt <schst@php.net>
  7.  * @uses    example.xml
  8.  */
  9.  
  10. require_once 'XML/Unserializer.php';
  11.  
  12. $options = array(
  13.                   XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE    => true,
  14.                   XML_UNSERIALIZER_OPTION_ATTRIBUTES_ARRAYKEY => false
  15.                 );
  16.  
  17. //  be careful to always use the ampersand in front of the new operator 
  18. $unserializer &new XML_Unserializer($options);
  19.  
  20. // userialize the document
  21. $status $unserializer->unserialize('example.xml'true);
  22.  
  23. if (PEAR::isError($status)) {
  24.     echo 'Error: ' $status->getMessage();
  25. else {
  26.     $data $unserializer->getUnserializedData();
  27.     echo '<pre>';
  28.     print_r($data);
  29.     echo '</pre>';
  30. }
  31. ?>

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