root/branches/PRE_NAMESPACES/examples/Example3.php

Revision 31, 1.3 kB (checked in by mikey, 2 years ago)

converted Example3

Line 
1 <?php
2 /**
3  * Example that shows how to use differant namespaces with same tags.
4  *
5  * @author  Stephan Schmidt <stephan.schmidt@schlund.de>
6  * @author  Frank Kleine <frank.kleine@schlund.de>
7  */
8 require_once '../XJConf/XJConfLoader.php';
9 XJConfLoader::load('DefinitionParser',
10                    'XmlParser'
11 );
12 require 'Color.php';
13 require 'Complex.php';
14 require 'UpperString.php';
15 /**
16  * Example that shows how to use differant namespaces with same tags.
17  *
18  * @package     XJConf
19  * @subpackage  examples
20  */
21 class Example3
22 {
23
24     public static function main()
25     {
26         $tagParser = new DefinitionParser();
27         $defs      = $tagParser->parse(getcwd() . '/xml/defines3.xml');
28
29         echo 'Defined namespaces: ';
30         foreach ($defs->getDefinedNamespaces() as $namespace) {
31             var_dump($namespace->getNamespaceURI());
32         }
33
34         $conf = new XmlParser();
35         try {
36             $conf->setTagDefinitions($defs);
37     
38             $conf->parse(getcwd() . '/xml/test3.xml');
39         } catch (Exception $e) {
40             echo $e->getTraceAsString();
41             exit(0);
42         }
43         
44         $zahl = $conf->getConfigValue('zahl');
45         echo 'Zahl:';
46         var_dump($zahl);
47         
48         $text = $conf->getConfigValue('text');
49         echo 'Text:';
50         var_dump($text);
51     }
52 }
53 Example3::main();
54 ?>
Note: See TracBrowser for help on using the browser.