-
Notifications
You must be signed in to change notification settings - Fork 0
/
xml.php
45 lines (41 loc) · 1.24 KB
/
xml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* XmlHelper
*
* Simple helper class that allows the user to concatenate
* XML documents or fragments based on the required elements.
*
* Use $instance->init to start a XML document
* Use $instance->open to open an element
* Use $instance->close to close # of (or all) elements
* Use $instance->single to append a self closing element
* Use $instance->element to append an element
* Use $instance->append to append raw content to the XML
*
* Typecasting $instance to (string) or calling $instance->render()
* will return all previously declared XML if $instance was created
* using $capture = true (default).
*
* @copyright Copyright (c) Dutchwise V.O.F. (http://dutchwise.nl)
* @author Max van Holten (<[email protected]>)
* @license http://www.opensource.org/licenses/mit-license.php MIT license
*/
if(!class_exists('XmlHelper')) {
class XmlHelper extends HtmlHelper {
/**
* Initiates the XML document.
*
* @param string $version
* @param string $encoding
* @return string
*/
public function init($version = '1.0', $encoding = 'UTF-8') {
$init = "<?xml version=\"{$version}\" encoding=\"{$encoding}\"?>";
if($this->_captureEnabled) {
$this->_output .= $init;
}
return $init;
}
}
}
?>