public function writeNode(SVGNode $node)
    {
        $this->outString .= '<'.$node->getName();

        $this->appendAttributes($node->getSerializableAttributes());
        $this->appendStyles($node->getSerializableStyles());

        $textContent = htmlspecialchars($node->getValue());

        if ($node instanceof SVGNodeContainer) {
            $this->outString .= '>';
            for ($i = 0, $n = $node->countChildren(); $i < $n; ++$i) {
                $this->writeNode($node->getChild($i));
            }
            $this->outString .= $textContent.'</'.$node->getName().'>';
            return;
        }

        if ($node instanceof SVGStyle) {
            $this->outString .= '>';
            $this->writeCdata($node->getCss());
            $this->outString .= $textContent.'</'.$node->getName().'>';
            return;
        }

        if (!empty($textContent)) {
            $this->outString .= '>' . $textContent . '</'.$node->getName().'>';
            return;
        }

        $this->outString .= ' />';
    }