final public function write($xml)
    {

        if($xml instanceof \SimpleXMLElement){
            $xml = $xml->asXML();
        } elseif($xml instanceof \DOMDocument){
            $xml = $xml->saveXML();
        }

        $this->log("SENT: ".$xml);

        return parent::write($xml);
    }