42 $this->attributes = array();
44 $this->children = array();
51 function getName($includeNamespace =
true) {
54 ($i = strpos($this->name,
':')) ===
false
56 return substr($this->name, $i+1);
92 return isset($this->attributes[
$name]) ? $this->attributes[
$name] :
null;
138 foreach ($this->children as $key => $junk) {
139 $child =& $this->children[$key];
140 if (in_array($child->getName(),
$name)) {
161 $returner =& $node->getValue();
172 $this->children[] =& $node;
179 function &
toXml($output =
null) {
183 if ($this->parent ===
null) {
185 $out .=
"<?xml version=\"" . $this->
getAttribute(
'version') .
"\" encoding=\"UTF-8\"?>\n";
195 if ($this->name !==
null) {
199 $out .=
" $name=\"$value\"";
201 if ($this->name !==
'!--') {
206 foreach ($this->children as $child) {
207 if ($output !==
null) {
208 if ($output ===
true) echo $out;
209 else fwrite ($output, $out);
212 $out .= $child->toXml($output);
214 if ($this->name ===
'!--') {
216 }
else if ($this->name !==
null) {
217 $out .=
'</' . $this->name .
'>';
219 if ($output !==
null) {
220 if ($output ===
true) echo $out;
221 else fwrite ($output, $out);
227 static function xmlentities($string, $quote_style=ENT_QUOTES) {
228 return htmlspecialchars($string, $quote_style,
'UTF-8');
232 unset($this->value, $this->attributes, $this->parent, $this->name);
233 foreach ($this->children as $child) {
236 unset($this->children);