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 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('Hähnchenflügel').'</de>
15
   </word>
16
 </dict>';
17
 
18
// specify different source and target encodings
19
$options = array(
20
                  XML_UNSERIALIZER_OPTION_ENCODING_SOURCE => 'UTF-8',
21
                  XML_UNSERIALIZER_OPTION_ENCODING_TARGET => '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
    echo '<pre>';
36
    print_r($data);
37
    echo '</pre>';
38
}
39
?>