root/trunk/examples/engine_automatic.php

Revision 42, 1.5 kB (checked in by argh, 3 years ago)

Added an example for the automatic engine.

Line 
1 <?php
2 /**
3  * Quickstart example
4  *
5  * @access        public
6  * @package        patXMLPretty
7  * @subpackage    Examples
8  * @author        Sebastian Mordziol <argh@php-tools.net>
9  * @license        LGPL, see license.txt for details
10  * @link        http://www.php-tools.net
11  */
12
13     /**
14      * Main examples prepend file, needed *only* for the examples framework!
15      */
16     include_once 'patExampleGen/prepend.php';
17     $exampleGen->displayHead( 'Example' );
18
19
20     // EXAMPLE START ------------------------------------------------------
21
22     /**
23      * The patXMLPretty main class
24      */
25     require_once $neededFiles['patXMLPretty'];
26
27     /**
28      * patErrorManager class
29      */
30     require_once $neededFiles['patErrorManager'];
31
32
33     // create a new XML pretty object
34     $pretty =& new patXMLPretty;
35
36     // create the engine
37     $engine =& $pretty->createEngine( 'Automatic' );
38
39     // give patXMLPretty the selected engine
40     $pretty->setEngine( $engine );
41
42     // highlight a file
43     $highlighted = $pretty->parseFile( 'data/sitemap.xml' );
44     if( patErrorManager::isError( $highlighted ) ) {
45         die( $highlighted->getMessage() );
46     }
47
48     // the automatic engine offers a special method to
49     // retrieve the engine object it uses.
50     $selectedEngine = $engine->getEngine();
51
52     // display the info on the selected engine
53     displaySection( 'Selected parsing engine', $selectedEngine->getName() );
54
55     // display the highlighted source
56     displaySection( 'Highlighted source', $highlighted );
57
58
59     // EXAMPLE END ------------------------------------------------------
60     $exampleGen->displayFooter();
61 ?>
62
Note: See TracBrowser for help on using the browser.