/* * call-seq: * dup * * Copy this node. An optional depth may be passed in, but it defaults * to a deep copy. 0 is a shallow copy, 1 is a deep copy. */ static VALUE duplicate_node(int argc, VALUE *argv, VALUE self) { VALUE level; if(rb_scan_args(argc, argv, "01", &level) == 0) level = INT2NUM(1); xmlNodePtr node, dup; Data_Get_Struct(self, xmlNode, node); dup = xmlDocCopyNode(node, node->doc, NUM2INT(level)); if(dup == NULL) return Qnil; return Nokogiri_wrap_xml_node(dup); }