### Home Classes Methods

### In Files

- lib/nokogiri/xml/sax/document.rb

### Parent

Object

### Methods

- #cdata_block
- #characters
- #comment
- #end_document
- #end_element
- #end_element_namespace
- #error
- #processing_instruction
- #start_document
- #start_element
- #start_element_namespace
- #warning
- #xmldecl

### Files

- CHANGELOG.ja.rdoc
- CHANGELOG.rdoc
- C_CODING_STYLE.rdoc
- Manifest.txt
- README.ja.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- Nokogiri
- Nokogiri::CSS
- Nokogiri::CSS::Node
- Nokogiri::CSS::Parser
- Nokogiri::CSS::SyntaxError
- Nokogiri::CSS::Tokenizer
- Nokogiri::CSS::Tokenizer::ScanError
- Nokogiri::Decorators
- Nokogiri::Decorators::Slop
- Nokogiri::EncodingHandler
- Nokogiri::HTML
- Nokogiri::HTML::Builder
- Nokogiri::HTML::Document
- Nokogiri::HTML::Document::EncodingReader
- Nokogiri::HTML::Document::EncodingReader::JumpSAXHandler
- Nokogiri::HTML::DocumentFragment
- Nokogiri::HTML::ElementDescription
- Nokogiri::HTML::EntityDescription
- Nokogiri::HTML::EntityLookup
- Nokogiri::HTML::SAX
- Nokogiri::HTML::SAX::Parser
- Nokogiri::HTML::SAX::ParserContext
- Nokogiri::HTML::SAX::PushParser
- Nokogiri::SyntaxError
- Nokogiri::XML
- Nokogiri::XML::Attr
- Nokogiri::XML::AttributeDecl
- Nokogiri::XML::Builder
- Nokogiri::XML::CDATA
- Nokogiri::XML::CharacterData
- Nokogiri::XML::Comment
- Nokogiri::XML::DTD
- Nokogiri::XML::Document
- Nokogiri::XML::DocumentFragment
- Nokogiri::XML::Element
- Nokogiri::XML::ElementContent
- Nokogiri::XML::ElementDecl
- Nokogiri::XML::EntityDecl
- Nokogiri::XML::EntityReference
- Nokogiri::XML::Namespace
- Nokogiri::XML::Node
- Nokogiri::XML::Node::SaveOptions
- Nokogiri::XML::NodeSet
- Nokogiri::XML::Notation
- Nokogiri::XML::PP
- Nokogiri::XML::PP::CharacterData
- Nokogiri::XML::PP::Node
- Nokogiri::XML::ParseOptions
- Nokogiri::XML::ProcessingInstruction
- Nokogiri::XML::Reader
- Nokogiri::XML::RelaxNG
- Nokogiri::XML::SAX
- Nokogiri::XML::SAX::Document
- Nokogiri::XML::SAX::Parser
- Nokogiri::XML::SAX::Parser::Attribute
- Nokogiri::XML::SAX::ParserContext
- Nokogiri::XML::SAX::PushParser
- Nokogiri::XML::Schema
- Nokogiri::XML::SyntaxError
- Nokogiri::XML::Text
- Nokogiri::XML::XPath
- Nokogiri::XML::XPath::SyntaxError
- Nokogiri::XML::XPathContext
- Nokogiri::XSLT
- Nokogiri::XSLT::Stylesheet
- XSD
- XSD::XMLParser
- XSD::XMLParser::Nokogiri
- Object

No matching classes.

# Nokogiri::XML::SAX::Document

This class is used for registering types of events you are interested in handling. All of the methods on this class are available as possible events while parsing an XML document. To register for any particular event, just subclass this class and implement the methods you are interested in knowing about.

To only be notified about start and end element events, write a class like this:

    class MyDocument < Nokogiri::XML::SAX::Document
      def start_element name, attrs = []
        puts "#{name} started!"
      end

      def end_element name
        puts "#{name} ended"
      end
    end

You can use this event handler for any SAX style parser included with Nokogiri. See Nokogiri::XML::SAX, and Nokogiri::HTML::SAX.

### Public Instance Methods

cdata_block(string) click to toggle source

Called when cdata blocks are found `string` contains the cdata content

    # File lib/nokogiri/xml/sax/document.rb, line 159
    def cdata_block string
    end

characters(string) click to toggle source

Characters read between a tag. This method might be called multiple times given one contiguous string of characters.

`string` contains the character data

    # File lib/nokogiri/xml/sax/document.rb, line 135
    def characters string
    end

comment(string) click to toggle source

Called when comments are encountered `string` contains the comment data

    # File lib/nokogiri/xml/sax/document.rb, line 141
    def comment string
    end

end_document() click to toggle source

Called when document ends parsing

    # File lib/nokogiri/xml/sax/document.rb, line 83
    def end_document
    end

end_element(name) click to toggle source

Called at the end of an element `name` is the tag name

    # File lib/nokogiri/xml/sax/document.rb, line 97
    def end_element name
    end

end_element_namespace(name, prefix = nil, uri = nil) click to toggle source

Called at the end of an element `name` is the element’s name `prefix` is the namespace prefix associated with the element `uri` is the associated namespace URI

    # File lib/nokogiri/xml/sax/document.rb, line 124
    def end_element_namespace name, prefix = nil, uri = nil
      ###
      # Deal with SAX v1 interface
      end_element [prefix, name].compact.join(':')
    end

error(string) click to toggle source

Called on document errors `string` contains the error

    # File lib/nokogiri/xml/sax/document.rb, line 153
    def error string
    end

processing_instruction(name, content) click to toggle source

Called when processing instructions are found `name` is the target of the instruction `content` is the value of the instruction

    # File lib/nokogiri/xml/sax/document.rb, line 166
    def processing_instruction name, content
    end

start_document() click to toggle source

Called when document starts parsing

    # File lib/nokogiri/xml/sax/document.rb, line 78
    def start_document
    end

start_element(name, attrs = []) click to toggle source

Called at the beginning of an element

- `name` is the name of the tag

- `attrs` are an assoc list of namespaces and attributes, e.g.:

      [ ["xmlns:foo", "http://sample.net"], ["size", "large"] ]

    # File lib/nokogiri/xml/sax/document.rb, line 91
    def start_element name, attrs = []
    end

start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) click to toggle source

Called at the beginning of an element `name` is the element name `attrs` is a list of attributes `prefix` is the namespace prefix for the element `uri` is the associated namespace URI `ns` is a hash of namespace prefix:urls associated with the element

    # File lib/nokogiri/xml/sax/document.rb, line 107
    def start_element_namespace name, attrs = [], prefix = nil, uri = nil, ns = []
      ###
      # Deal with SAX v1 interface
      name = [prefix, name].compact.join(':')
      attributes = ns.map { |ns_prefix,ns_uri|
        [['xmlns', ns_prefix].compact.join(':'), ns_uri]
      } + attrs.map { |attr|
        [[attr.prefix, attr.localname].compact.join(':'), attr.value]
      }
      start_element name, attributes
    end

warning(string) click to toggle source

Called on document warnings `string` contains the warning

    # File lib/nokogiri/xml/sax/document.rb, line 147
    def warning string
    end

xmldecl(version, encoding, standalone) click to toggle source

Called when an XML declaration is parsed

    # File lib/nokogiri/xml/sax/document.rb, line 73
    def xmldecl version, encoding, standalone
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.