public function toString($indentWith = null) { foreach ($this->attributes as $name => $value) { $position = 0; foreach ($this as $node) { if ($node instanceof ar_xmlElement) { $appliedValue = $this->_applyValues($value, $position); $node->setAttribute($name, $appliedValue); $position++; } } } $result = ''; $position = 0; foreach ($this as $node) { if ($node instanceof ar_xmlElement) { $result .= $node->toString($indentWith, $position); $position++; } else { if ($node instanceof ar_xmlNode) { $stringValue = (string) $node; if (trim($stringValue) !== "") { $result .= $stringValue; } } else { if ($node instanceof ar_xmlNodes) { $result .= $node->toString($indentWith); } else { if (is_string($node)) { $node = trim($node); if ($node !== "") { $result .= ar_xml::indent((string) $node, $indentWith); } } } } } } return $result; }