root/trunk/examples/Example3.php

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

renamed XJConfLoader to XJConf

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/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 differant namespaces with same tags.
16  *
17  * @package     XJConf
18  * @subpackage  examples
19  */
20 class Example3
21 {
22
23     public static function main()
24     {
25         $tagParser = new DefinitionParser();
26         $defs      = $tagParser->parse(getcwd() . '/xml/defines3.xml');
27
28         echo 'Defined namespaces: ';
29         foreach ($defs->getDefinedNamespaces() as $namespace) {
30             var_dump($namespace->getNamespaceURI());
31         }
32
33         $conf = new XmlParser();
34         try {
35             $conf->setTagDefinitions($defs);
36     
37             $conf->parse(getcwd() . '/xml/test3.xml');
38         } catch (Exception $e) {
39             echo $e->getTraceAsString();
40             exit(0);
41         }
42         
43         $zahl = $conf->getConfigValue('zahl');
44         echo 'Zahl:';
45         var_dump($zahl);
46         
47         $text = $conf->getConfigValue('text');
48         echo 'Text:';
49         var_dump($text);
50     }
51 }
52 Example3::main();
53 ?>
Note: See TracBrowser for help on using the browser.