src/Writing/SVGWriter.php
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 .= ' />';
    }
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 .= ' />';
    }
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 .= ' />' ; }
Converts the given node into its XML representation and appends that to
this writer's output string.

The generated string contains the attributes defined via
SVGNode::getSerializableAttributes() and the styles defined via
SVGNode::getSerializableStyles().
Container nodes (<g></g>) and self-closing tags (<rect />) are
distinguished correctly.

@param SVGNode $node The node to write.

@return void
Converts the given node into its XML representation and appends that to this writer s output string .