root/trunk/examples/Example2.php

Revision 129, 1.4 kB (checked in by mikey, 1 year ago)

renamed XJConfLoader to XJConf

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