Class: Nokogiri::XML::CData

Inherits:
NokogiriXmlNode
  • Object
show all
Defined in:
ext/nokogiri/xml_cdata.c

Class Method Summary collapse

Class Method Details

.new(doc, content) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'ext/nokogiri/xml_cdata.c', line 8

static VALUE new(VALUE klass, VALUE doc, VALUE content)
{
  xmlDocPtr xml_doc;
  Data_Get_Struct(doc, xmlDoc, xml_doc);

  xmlNodePtr node = xmlNewCDataBlock(
      xml_doc,
      (const xmlChar *)StringValuePtr(content),
      NUM2INT(rb_funcall(content, rb_intern("length"), 0))
  );

  VALUE rb_node = Data_Wrap_Struct(klass, NULL, dealloc, node);
  node->_private = (void *)rb_node;

  if(rb_block_given_p()) rb_yield(rb_node);

  return rb_node;
}