src/Reading/SVGReader.php
public function parseXML(\SimpleXMLElement $xml)
    {
        $name = $xml->getName();
        if ($name !== 'svg') {
            return null;
        }

        $width = isset($xml['width']) ? $xml['width'] : null;
        $height = isset($xml['height']) ? $xml['height'] : null;
        $namespaces = $xml->getNamespaces(true);

        $img = new SVG($width, $height, $namespaces);

        $nsKeys = array_keys($namespaces);

        $doc = $img->getDocument();
        $this->applyAttributes($doc, $xml, $nsKeys);
        $this->applyStyles($doc, $xml);
        $this->addChildren($doc, $xml, $nsKeys);

        return $img;
    }
public function parseXML(\SimpleXMLElement $xml)
    {
        $name = $xml->getName();
        if ($name !== 'svg') {
            return null;
        }

        $width = isset($xml['width']) ? $xml['width'] : null;
        $height = isset($xml['height']) ? $xml['height'] : null;
        $namespaces = $xml->getNamespaces(true);

        $img = new SVG($width, $height, $namespaces);

        $nsKeys = array_keys($namespaces);

        $doc = $img->getDocument();
        $this->applyAttributes($doc, $xml, $nsKeys);
        $this->applyStyles($doc, $xml);
        $this->addChildren($doc, $xml, $nsKeys);

        return $img;
    }
public function parseXML ( \ SimpleXMLElement $ xml ) { $ name = $ xml -> getName ( ) ; if ( $ name !== 'svg' ) { return null ; } $ width = isset ( $ xml [ 'width' ] ) ? $ xml [ 'width' ] : null ; $ height = isset ( $ xml [ 'height' ] ) ? $ xml [ 'height' ] : null ; $ namespaces = $ xml -> getNamespaces ( true ) ; $ img = new SVG ( $ width , $ height , $ namespaces ) ; $ nsKeys = array_keys ( $ namespaces ) ; $ doc = $ img -> getDocument ( ) ; $ this -> applyAttributes ( $ doc , $ xml , $ nsKeys ) ; $ this -> applyStyles ( $ doc , $ xml ) ; $ this -> addChildren ( $ doc , $ xml , $ nsKeys ) ; return $ img ; }
Parses the given XML document into an instance of SVG.
Returns null when parsing fails.

@param \SimpleXMLElement $xml The root node of the SVG document to parse.

@return SVG|null An image object representing the parse result.
Parses the given XML document into an instance of SVG . Returns null when parsing fails .