Class: LibXML::XML::Parser

### Home Classes Methods

### In Files

- lib/libxml/parser.rb

### Parent

Object

### Methods

- ::document
- ::file
- ::io
- ::register_error_handler
- ::string

### Class/Module Index

Quicksearch

- LibXML
- LibXML::XML
- LibXML::XML::Attr
- LibXML::XML::AttrDecl
- LibXML::XML::Attributes
- LibXML::XML::Document
- LibXML::XML::Error
- LibXML::XML::HTMLParser
- LibXML::XML::Namespace
- LibXML::XML::Namespaces
- LibXML::XML::Node
- LibXML::XML::Parser
- LibXML::XML::Reader
- LibXML::XML::SaxParser
- LibXML::XML::SaxParser::Callbacks
- LibXML::XML::SaxParser::VerboseCallbacks
- LibXML::XML::Schema
- LibXML::XML::Schema::Attribute
- LibXML::XML::Schema::Element
- LibXML::XML::Schema::Namespaces
- LibXML::XML::Schema::Type
- LibXML::XML::Schema::Types
- LibXML::XML::XPath
- LibXML::XML::XPath::Object
- Object

No matching classes.

# LibXML::XML::Parser

### Public Class Methods

XML::Parser.document(document) → XML::Parser click to toggle source

Creates a new parser for the specified document.

Parameters:

    document - A preparsed document.

    # File lib/libxml/parser.rb, line 13
    def self.document(doc)
      context = XML::Parser::Context.document(doc)
      self.new(context)
    end

XML::Parser.file(path) → XML::Parser click to toggle source
XML::Parser.file(path, :encoding => XML::Encoding::UTF_8,
:options => XML::Parser::Options::NOENT) → XML::Parser

Creates a new parser for the specified file or uri.

You may provide an optional hash table to control how the parsing is performed. Valid options are:

    encoding - The document encoding, defaults to nil. Valid values
               are the encoding constants defined on XML::Encoding.
    options - Parser options.  Valid values are the constants defined on
              XML::Parser::Options.  Mutliple options can be combined
              by using Bitwise OR (|).

    # File lib/libxml/parser.rb, line 33
    def self.file(path, options = {})
      context = XML::Parser::Context.file(path)
      context.encoding = options[:encoding] if options[:encoding]
      context.options = options[:options] if options[:options]
      self.new(context)
    end

XML::Parser.io(io) → XML::Parser click to toggle source
XML::Parser.io(io, :encoding => XML::Encoding::UTF_8,
:options => XML::Parser::Options::NOENT
:base_uri="http://libxml.org") → XML::Parser

Creates a new parser for the specified io object.

Parameters:

    io - io object that contains the xml to parser
    base_uri - The base url for the parsed document.
    encoding - The document encoding, defaults to nil. Valid values
               are the encoding constants defined on XML::Encoding.
    options - Parser options.  Valid values are the constants defined on
              XML::Parser::Options.  Mutliple options can be combined
              by using Bitwise OR (|).

    # File lib/libxml/parser.rb, line 57
    def self.io(io, options = {})
      context = XML::Parser::Context.io(io)
      context.base_uri = options[:base_uri] if options[:base_uri]
      context.encoding = options[:encoding] if options[:encoding]
      context.options = options[:options] if options[:options]
      self.new(context)
    end

register_error_handler(proc) click to toggle source

    # File lib/libxml/parser.rb, line 90
    def self.register_error_handler(proc)
      warn('Parser.register_error_handler is deprecated.  Use Error.set_handler instead')
      if proc.nil?
        Error.reset_handler
      else
        Error.set_handler(&proc)
      end
    end

XML::Parser.string(string) click to toggle source
XML::Parser.string(string, :encoding => XML::Encoding::UTF_8,
:options => XML::Parser::Options::NOENT
:base_uri="http://libxml.org") → XML::Parser

Creates a new parser by parsing the specified string.

You may provide an optional hash table to control how the parsing is performed. Valid options are:

    base_uri - The base url for the parsed document.
    encoding - The document encoding, defaults to nil. Valid values
               are the encoding constants defined on XML::Encoding.
    options - Parser options.  Valid values are the constants defined on
              XML::Parser::Options.  Mutliple options can be combined
              by using Bitwise OR (|).

    # File lib/libxml/parser.rb, line 82
    def self.string(string, options = {})
      context = XML::Parser::Context.string(string)
      context.base_uri = options[:base_uri] if options[:base_uri]
      context.encoding = options[:encoding] if options[:encoding]
      context.options = options[:options] if options[:options]
      self.new(context)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.