This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
/
Xml.php
97 lines (88 loc) · 1.85 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Contains the class T_Xml.
*
* @package core
* @author Rob Tuley
* @version SVN: $Id$
* @license http://knotwerk.com/licence MIT
*/
/**
* simpleXML class wrapper.
*
* A wrapper class for the SimpleXmlElement class. The reason this wrapper
* class is created is that the SimpleXml object's constructor cannot be
* extended. This wrapper circumvents that restriction and is used for example
* in T_Xhtml_UrlSitemap.
*
* @package core
* @license http://knotwerk.com/licence MIT
*/
class T_Xml
{
/**
* XML class wrapper.
*
* @var T_Xml_Element
*/
protected $sxe;
/**
* Create XML base class.
*
* @param unknown_type $xml
*/
function __construct($xml)
{
$this->sxe = new T_Xml_Element($xml);
}
/**
* Transfer all method class to SimpleXml object.
*
* @param string $method method name
* @param array $args method arguments
* @return mixed
*/
function __call($method, $args)
{
return call_user_func_array(array($this->sxe,$method),$args);
}
/**
* Get SimpleXml element.
*
* @param string $property child element name
* @return T_Xml_Element child element property
*/
function __get($property)
{
return $this->sxe->$property;
}
/**
* Set value of child element.
*
* @param string $property
* @param mixed $value
* @return mixed
*/
function __set($property,$value)
{
return $this->sxe->$property = $value;
}
/**
* Get XML representation.
*
* @return string XML string
*/
function asXml()
{
return $this->sxe->asXML();
}
/**
* Return XML string representation.
*
* @return string XML string
*/
function __toString()
{
return $this->asXml();
}
}