Prado\Xml\TXmlElement::toString PHP Method

toString() public method

public toString ( $indent ) : string
return string string representation of this element
    public function toString($indent = 0)
    {
        $attr = '';
        if ($this->_attributes !== null) {
            foreach ($this->_attributes as $name => $value) {
                $value = $this->xmlEncode($value);
                $attr .= " {$name}=\"{$value}\"";
            }
        }
        $prefix = str_repeat(' ', $indent * 4);
        if ($this->getHasElement()) {
            $str = $prefix . "<{$this->_tagName}{$attr}>\n";
            foreach ($this->getElements() as $element) {
                $str .= $element->toString($indent + 1) . "\n";
            }
            $str .= $prefix . "</{$this->_tagName}>";
            return $str;
        } else {
            if (($value = $this->getValue()) !== '') {
                $value = $this->xmlEncode($value);
                return $prefix . "<{$this->_tagName}{$attr}>{$value}</{$this->_tagName}>";
            } else {
                return $prefix . "<{$this->_tagName}{$attr} />";
            }
        }
    }