class XML::SAX

Overview

Simple API for XML.

Parses XML documents using a push-parser; whenever something is reached, for example an element starts, or a comment is reached, a callback is called with details about the event. Custom handlers can then do anything they want using these information: stream the document while reacting to certain elements and skipping the rest, or build a complete DOM tree, or a partial tree without declarations, comments or processing instructions.

See Handlers for the list of methods that will be called during parsing.

TODO options to enable parsing entities, etc.

Included Modules

Defined in:

sax.cr
sax/attributes.cr
sax/element_decl.cr
sax/entities.cr
sax/error.cr
sax/handlers.cr
sax/reader.cr

Constructors

Instance Method Summary

Instance methods inherited from module XML::Chars

char?(version : Symbol, char : Char | Nil) : Bool char?, encname?(char : Char | Nil) : Bool encname?, encname_start?(char : Char | Nil) : Bool encname_start?, name?(char : Char | Nil) : Bool name?, name_start?(char : Char) : Bool name_start?, pubid?(char : Char | Nil) : Bool pubid?, quote?(char : Char | Nil) : Bool quote?, restricted?(char : Char | Nil) : Bool restricted?, s?(char : Char) : Bool s?

Constructor Detail

def self.new(io : IO, handlers : Handlers) #

[View source]

Instance Method Detail

def base : String #

[View source]
def base=(value : String | Nil) #

[View source]
def base? : String | Nil #

[View source]
def ignore_whitespace=(ignore_whitespace : Bool) #

[View source]
def ignore_whitespace? : Bool #

[View source]
def location : Location #

Returns the current location.


[View source]
def parse : Nil #

Parse IO as a XML document.

Raises Error on fatal errors.


[View source]
def parse_version_info : String #

[View source]
def version : Symbol #

[View source]
def version=(value : Symbol) #

[View source]