Variant f_simplexml_import_dom(CObjRef node,
                               const String& class_name /* = "SimpleXMLElement" */) {

  c_DOMNode *domnode = node.getTyped<c_DOMNode>();
  xmlNodePtr nodep = domnode->m_node;

  if (nodep) {
    if (nodep->doc == nullptr) {
      raise_warning("Imported Node must have associated Document");
      return uninit_null();
    }
    if (nodep->type == XML_DOCUMENT_NODE ||
        nodep->type == XML_HTML_DOCUMENT_NODE) {
      nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
    }
  }

  if (nodep && nodep->type == XML_ELEMENT_NODE) {
    Resource obj =
      Resource(NEWOBJ(XmlDocWrapper)(nodep->doc, class_name, node));
    return create_element(nullptr, obj, nodep, String(), false);
  } else {
    raise_warning("Invalid Nodetype to import");
    return uninit_null();
  }
}
Variant f_simplexml_import_dom(CObjRef node,
                               const String& class_name  ) {

  c_DOMNode *domnode = node.getTyped<c_DOMNode>();
  xmlNodePtr nodep = domnode->m_node;

  if (nodep) {
    if (nodep->doc == nullptr) {
      raise_warning("Imported Node must have associated Document");
      return uninit_null();
    }
    if (nodep->type == XML_DOCUMENT_NODE ||
        nodep->type == XML_HTML_DOCUMENT_NODE) {
      nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
    }
  }

  if (nodep && nodep->type == XML_ELEMENT_NODE) {
    Resource obj =
      Resource(NEWOBJ(XmlDocWrapper)(nodep->doc, class_name, node));
    return create_element(nullptr, obj, nodep, String(), false);
  } else {
    raise_warning("Invalid Nodetype to import");
    return uninit_null();
  }
}