Sha256: 0e72c103f1230fe80148514aaf92b74437b189c6f838e9d0334d11e97455589c

Contents?: true

Size: 905 Bytes

Versions: 3

Compression:

Stored size: 905 Bytes

Contents

#include <xml_document_fragment.h>

/*
 * call-seq:
 *  new(document)
 *
 * Create a new DocumentFragment element on the +document+
 */
static VALUE new(VALUE klass, VALUE doc)
{
  xmlDocPtr xml_doc;
  Data_Get_Struct(doc, xmlDoc, xml_doc);

  xmlNodePtr node = xmlNewDocFragment(xml_doc->doc);

  VALUE rb_node = Nokogiri_wrap_xml_node(node);

  if(rb_block_given_p()) rb_yield(rb_node);

  return rb_node;
}

VALUE cNokogiriXmlDocumentFragment;
void init_xml_document_fragment()
{
  VALUE nokogiri = rb_define_module("Nokogiri");
  VALUE xml = rb_define_module_under(nokogiri, "XML");
  VALUE node = rb_define_class_under(xml, "Node", rb_cObject);

  /*
   * DocumentFragment represents a DocumentFragment node in an xml document.
   */
  VALUE klass = rb_define_class_under(xml, "DocumentFragment", node);

  cNokogiriXmlDocumentFragment = klass;

  rb_define_singleton_method(klass, "new", new, 1);
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nokogiri-1.2.2-java ext/nokogiri/xml_document_fragment.c
nokogiri-1.2.2-x86-mswin32-60 ext/nokogiri/xml_document_fragment.c
nokogiri-1.2.2 ext/nokogiri/xml_document_fragment.c