Method: Nokogiri::XML::NodeSet#delete

Defined in:
ext/nokogiri/xml_node_set.c

#delete(node) ⇒ Object

Delete node from the Nodeset, if it is a member. Returns the deleted node if found, otherwise returns nil.


180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'ext/nokogiri/xml_node_set.c', line 180

static VALUE
delete (VALUE rb_self, VALUE rb_node)
{
  xmlNodeSetPtr c_self;
  xmlNodePtr node;

  Check_Node_Set_Node_Type(rb_node);

  TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
  Noko_Node_Get_Struct(rb_node, xmlNode, node);

  if (xmlXPathNodeSetContains(c_self, node)) {
    xpath_node_set_del(c_self, node);
    return rb_node;
  }
  return Qnil ;
}