Create a new DocumentFragment from tags.
If ctx is present, it is used as a context node for the subtree created, e.g., namespaces will be resolved relative to ctx.
# File lib/nokogiri/xml/document_fragment.rb, line 10 10: def initialize document, tags = nil, ctx = nil 11: return self unless tags 12: 13: children = if ctx 14: # Fix for issue#490 15: if Nokogiri.jruby? 16: ctx.parse("<root>#{tags}</root>").xpath("/root/node()") 17: else 18: ctx.parse(tags) 19: end 20: else 21: XML::Document.parse("<root>#{tags}</root>") .xpath("/root/node()") 22: end 23: children.each { |child| child.parent = self } 24: end
Create a new DocumentFragment element on the document
static VALUE new(int argc, VALUE *argv, VALUE klass) { xmlDocPtr xml_doc; xmlNodePtr node; VALUE document; VALUE rest; VALUE rb_node; rb_scan_args(argc, argv, "1*", &document, &rest); Data_Get_Struct(document, xmlDoc, xml_doc); node = xmlNewDocFragment(xml_doc->doc); nokogiri_root_node(node); rb_node = Nokogiri_wrap_xml_node(klass, node); rb_obj_call_init(rb_node, argc, argv); if(rb_block_given_p()) rb_yield(rb_node); return rb_node; }
Create a Nokogiri::XML::DocumentFragment from tags
# File lib/nokogiri/xml/document_fragment.rb, line 89 89: def parse tags 90: self.new(XML::Document.new, tags) 91: end
Search this fragment. See Nokogiri::XML::Node#css
# File lib/nokogiri/xml/document_fragment.rb, line 76 76: def css *args 77: if children.any? 78: children.css(*args) 79: else 80: NodeSet.new(document) 81: end 82: end
return the name for DocumentFragment
# File lib/nokogiri/xml/document_fragment.rb, line 29 29: def name 30: '#document-fragment' 31: end
Convert this DocumentFragment to html See Nokogiri::XML::NodeSet#to_html
# File lib/nokogiri/xml/document_fragment.rb, line 42 42: def to_html *args 43: if Nokogiri.jruby? 44: options = args.first.is_a?(Hash) ? args.shift : {} 45: if !options[:save_with] 46: options[:save_with] = Node::SaveOptions::NO_DECLARATION | Node::SaveOptions::NO_EMPTY_TAGS | Node::SaveOptions::AS_HTML 47: end 48: args.insert(0, options) 49: end 50: children.to_html(*args) 51: end
Convert this DocumentFragment to a string
# File lib/nokogiri/xml/document_fragment.rb, line 35 35: def to_s 36: children.to_s 37: end
Convert this DocumentFragment to xhtml See Nokogiri::XML::NodeSet#to_xhtml
# File lib/nokogiri/xml/document_fragment.rb, line 56 56: def to_xhtml *args 57: if Nokogiri.jruby? 58: options = args.first.is_a?(Hash) ? args.shift : {} 59: if !options[:save_with] 60: options[:save_with] = Node::SaveOptions::NO_DECLARATION | Node::SaveOptions::NO_EMPTY_TAGS | Node::SaveOptions::AS_XHTML 61: end 62: args.insert(0, options) 63: end 64: children.to_xhtml(*args) 65: end
Convert this DocumentFragment to xml See Nokogiri::XML::NodeSet#to_xml
# File lib/nokogiri/xml/document_fragment.rb, line 70 70: def to_xml *args 71: children.to_xml(*args) 72: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.