indent = $indent; $this->xml = '' . "\n"; } function _indent() { for ($i = 0, $j = count($this->stack); $i < $j; $i++) { $this->xml .= $this->indent; } } function push($element, $attributes = array()) { $this->_indent(); $this->xml .= '<' . $element; foreach ($attributes as $key => $value) { $this->xml .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($value) . '"'; } $this->xml .= ">\n"; $this->stack[] = htmlspecialchars($element); } function element($element, $content, $attributes = array()) { $this->_indent(); $this->xml .= '<' . $element; foreach ($attributes as $key => $value) { $this->xml .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($value) . '"'; } $this->xml .= '>' . htmlspecialchars($content) . '' . "\n"; } function emptyelement($element, $attributes = array()) { $this->_indent(); $this->xml .= '<' . htmlspecialchars($element); foreach ($attributes as $key => $value) { $this->xml .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($value) . '"'; } $this->xml .= " />\n"; } function pop() { $element = array_pop($this->stack); $this->_indent(); $this->xml .= "" . "\n"; } function getXml() { return $this->xml; } }