# File lib/nokogiri/xml/document_fragment.rb, line 4 def initialize document, tags=nil if tags if self.kind_of?(Nokogiri::HTML::DocumentFragment) HTML::SAX::Parser.new(FragmentHandler.new(self, tags)).parse(tags) else wrapped = "<div>#{tags.strip}</div>" XML::SAX::Parser.new(FragmentHandler.new(self, wrapped)).parse(wrapped) div = self.child div.children.each { |child| child.parent = self } div.unlink end end end