public function setAttributes(array $attr, $ns = null)
    {
        $dom = dom_import_simplexml($this);
        foreach ($attr as $k => $v) {
            $dom->setAttributeNS($ns, $k, $v);
        }
        return $this;
    }