root/branches/PRE_NAMESPACES/examples/Example2.php

Revision 30, 1.4 kB (checked in by mikey, 2 years ago)

converted Example2

Line 
1 <?php
2 /**
3  * Example that shows how to use ArrayList and the keyAttribute.
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 ArrayList and the keyAttribute.
17  *
18  * @package     XJConf
19  * @subpackage  examples
20  */
21 class Example2
22 {
23
24     public static function main()
25     {
26         $tagParser = new DefinitionParser();
27         $defs      = $tagParser->parse(getcwd() . '/xml/defines2.xml');
28
29         echo 'Number of defined tags: ';
30         var_dump($defs->countTagDefinitions());
31
32         $conf = new XmlParser();
33         try {
34             $conf->setTagDefinitions($defs);
35     
36             $conf->parse(getcwd() . '/xml/test2.xml');
37         } catch (Exception $e) {
38             echo $e->getTraceAsString();
39             exit(0);
40         }
41         
42         $one = $conf->getConfigValue('one');
43         echo 'One:';
44         var_dump($one);
45         
46         $two = $conf->getConfigValue('two');
47         echo 'Two:';
48         var_dump($two);
49         
50         $three = $conf->getConfigValue('three');
51         echo 'Three:';
52         var_dump($three);
53
54         $colors = $conf->getConfigValue('colors');
55         echo 'Colors:';
56         var_dump($colors);
57     }
58 }
59 Example2::main();
60 ?>
Note: See TracBrowser for help on using the browser.