root/trunk/examples/example_api_toxml_ns.php

Revision 117, 1.5 kB (checked in by argh, 4 years ago)

Massive update of the examples collection; added the patExampleGen examples framework; commented all examples; reworked all the templates...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * Example that shows how to serialize an element to XML with a namespace
4  *
5  * $Id$
6  *
7  * @access        public
8  * @package        patForms
9  * @subpackage    Examples
10  * @author        Sebastian Mordziol <argh@php-tools.net>
11  * @license        LGPL, see license.txt for details
12  * @link        http://www.php-tools.net
13  */
14
15     /**
16      * Main examples prepend file, needed *only* for the examples framework!
17      */
18     include_once 'patExampleGen/prepend.php';
19     $exampleGen->displayHead( 'Example' );
20
21     
22     // EXAMPLE START ------------------------------------------------------
23
24     /**
25      * main patForms class
26      */
27     require_once $neededFiles['patForms'];
28     
29     /**
30      * patErrorManager class
31      */
32     require_once $neededFiles['patErrorManager'];
33
34
35     // attribute collection for the element
36     $attributes    =    array(
37         'required'        =>    'yes',
38         'display'        =>    'yes',
39         'edit'            =>    'yes',
40         'label'            =>    'Username',
41         'description'    =>    'Enter your username here.',
42         'default'        =>    'Tom & Jerry',
43         'title'            =>    'Username',
44     );
45     
46     // create the element
47     $el = patForms::createElement( 'toXML', 'String', $attributes );
48     
49     // display the element
50     echo $el->getAttribute( 'label' )."<br>";
51     echo "<div>".$el->serialize()."</div>";
52     echo "<i>".$el->getAttribute( 'description' )."</i><br><br>";
53     
54     // serialize the element to xml with namespace
55     $xml = $el->toXML( 'patForms' );
56
57     // display the xml (we use the example framwrok's XML hilighter for this)
58     echo 'XML output:<br><br>';
59     $exampleGen->displayXMLString( $xml );
60
61
62     
63     
64     // EXAMPLE END ------------------------------------------------------
65     $exampleGen->displayFooter();
66 ?>
Note: See TracBrowser for help on using the browser.