Sha256: 8b0e44c436529fa01c67fb031339363622a7cfe3c21c783523d00dd184f98b3f

Contents?: true

Size: 1.44 KB

Versions: 12

Compression:

Stored size: 1.44 KB

Contents

module Nokogiri
  module HTML
    ###
    # Nokogiri lets you write a SAX parser to process HTML but get HTML
    # correction features.
    #
    # See Nokogiri::HTML::SAX::Parser for a basic example of using a
    # SAX parser with HTML.
    #
    # For more information on SAX parsers, see Nokogiri::XML::SAX
    module SAX
      ###
      # This class lets you perform SAX style parsing on HTML with HTML
      # error correction.
      #
      # Here is a basic usage example:
      #
      #   class MyDoc < Nokogiri::XML::SAX::Document
      #     def start_element name, attributes = []
      #       puts "found a #{name}"
      #     end
      #   end
      #
      #   parser = Nokogiri::HTML::SAX::Parser.new(MyDoc.new)
      #   parser.parse(File.read(ARGV[0], 'rb'))
      #
      # For more information on SAX parsers, see Nokogiri::XML::SAX
      class Parser < Nokogiri::XML::SAX::Parser
        ###
        # Parse html stored in +data+ using +encoding+
        def parse_memory data, encoding = 'UTF-8'
          raise ArgumentError unless data
          native_parse_memory(data, encoding)
        end

        ###
        # Parse a file with +filename+
        def parse_file filename, encoding = 'UTF-8'
          raise ArgumentError unless filename
          raise Errno::ENOENT unless File.exists?(filename)
          raise Errno::EISDIR if File.directory?(filename)
          native_parse_file filename, encoding
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
nokogiri-1.3.2-x86-mswin32 lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.2-x86-mingw32 lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.2-java lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.0-x86-mingw32 lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.2 lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.0-java lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.0 lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.1-x86-mingw32 lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.0-x86-mswin32 lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.1-java lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.1-x86-mswin32 lib/nokogiri/html/sax/parser.rb
nokogiri-1.3.1 lib/nokogiri/html/sax/parser.rb