Class: Nokogiri::XML::ProcessingInstruction

Inherits:
Node
  • Object
show all
Defined in:
lib/nokogiri/xml/processing_instruction.rb,
ext/nokogiri/xml_processing_instruction.c

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, name, content) ⇒ ProcessingInstruction

Returns a new instance of ProcessingInstruction.


5
6
# File 'lib/nokogiri/xml/processing_instruction.rb', line 5

def initialize document, name, content
end

Class Method Details

.new(document, name, content) ⇒ Object

Create a new ProcessingInstruction element on the document with name and content


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'ext/nokogiri/xml_processing_instruction.c', line 12

static VALUE
new (int argc, VALUE *argv, VALUE klass)
{
  xmlDocPtr xml_doc;
  xmlNodePtr node;
  VALUE document;
  VALUE name;
  VALUE content;
  VALUE rest;
  VALUE rb_node;

  rb_scan_args(argc, argv, "3*", &document, &name, &content, &rest);

  Data_Get_Struct(document, xmlDoc, xml_doc);

  node = xmlNewDocPI(
           xml_doc,
           (const xmlChar *)StringValueCStr(name),
           (const xmlChar *)StringValueCStr(content)
         );

  noko_xml_document_pin_node(node);

  rb_node = noko_xml_node_wrap(klass, node);
  rb_obj_call_init(rb_node, argc, argv);

  if (rb_block_given_p()) { rb_yield(rb_node); }

  return rb_node;
}