# class Loofah::HTML::DocumentFragment

Subclass of Nokogiri::HTML::DocumentFragment.

See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.

### Public Class Methods

parse(tags, encoding = nil) click to toggle source

Overridden Nokogiri::HTML::DocumentFragment constructor. Applications should use Loofah.fragment to parse a fragment.

    # File lib/loofah/html/document_fragment.rb, line 17
    def parse tags, encoding = nil
      doc = Loofah::HTML::Document.new

      encoding ||= tags.respond_to?(:encoding) ? tags.encoding.name : 'UTF-8'
      doc.encoding = encoding

      new(doc, tags)
    end

### Public Instance Methods

serialize()
Alias for: to_s
serialize_root() click to toggle source

    # File lib/loofah/html/document_fragment.rb, line 35
    def serialize_root
      at_xpath("./body") || self
    end

to_s() click to toggle source

Returns the HTML markup contained by the fragment

    # File lib/loofah/html/document_fragment.rb, line 30
    def to_s
      serialize_root.children.to_s
    end

Also aliased as: serialize