public function convert()
    {
        //Cache result if you want to run it multiple times
        if (!empty($this->output))
        {
            return $this->output;
        }

        if (empty($this->data))
        {
            throw new \Exception("No data specified!");
        }

        $this->output = '<?xml version="' . static::XML_VERSION . '" encoding="' . static::XML_ENCODING . '"?>' . PHP_EOL;

        $this->convertNodeToXML($this->data, $this->rootNode, 0);

        $this->output = trim($this->output);

        return $this->output;
    }
public function convert()
    {
        //Cache result if you want to run it multiple times
        if (!empty($this->output))
        {
            return $this->output;
        }

        if (empty($this->data))
        {
            throw new \Exception("No data specified!");
        }

        $this->output = '<?xml version="' . static::XML_VERSION . '" encoding="' . static::XML_ENCODING . '"?>' . PHP_EOL;

        $this->convertNodeToXML($this->data, $this->rootNode, 0);

        $this->output = trim($this->output);

        return $this->output;
    }
public function convert ( ) { //Cache result if you want to run it multiple times if ( ! empty ( $ this -> output ) ) { return $ this -> output ; } if ( empty ( $ this -> data ) ) { throw new \ Exception ( "No data specified!" ) ; } $ this -> output = '<?xml version="' . static :: XML_VERSION . '" encoding="' . static :: XML_ENCODING . '"?>' . PHP_EOL ; $ this -> convertNodeToXML ( $ this -> data , $ this -> rootNode , 0 ) ; $ this -> output = trim ( $ this -> output ) ; return $ this -> output ; }
Perform the conversion

@return string
@throws \Exception
Perform the conversion