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
Parse a file with filename
# File lib/nokogiri/html/sax/parser.rb, line 41 41: def parse_file filename, encoding = 'UTF-8' 42: raise ArgumentError unless filename 43: raise Errno::ENOENT unless File.exists?(filename) 44: raise Errno::EISDIR if File.directory?(filename) 45: ctx = ParserContext.file(filename, encoding) 46: yield ctx if block_given? 47: ctx.parse_with self 48: end
Parse html stored in data using encoding
# File lib/nokogiri/html/sax/parser.rb, line 31 31: def parse_memory data, encoding = 'UTF-8' 32: raise ArgumentError unless data 33: return unless data.length > 0 34: ctx = ParserContext.memory(data, encoding) 35: yield ctx if block_given? 36: ctx.parse_with self 37: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.