Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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
error_reporting(E_ALL);
10
 
11
require_once 'XML/Unserializer.php';
12
 
13
$options = array(
14
                  XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE    => true,
15
                  XML_UNSERIALIZER_OPTION_ATTRIBUTES_ARRAYKEY => false
16
                );
17
 
18
//  be careful to always use the ampersand in front of the new operator
19
$unserializer = &new XML_Unserializer($options);
20
 
21
// userialize the document
22
$status = $unserializer->unserialize('example.xml', true);
23
 
24
if (PEAR::isError($status)) {
25
    echo 'Error: ' . $status->getMessage();
26
} else {
27
    $data = $unserializer->getUnserializedData();
28
    echo '<pre>';
29
    print_r($data);
30
    echo '</pre>';
31
}
32
?>