Class LibXML::XML::Parser
In: ext/libxml/libxml.c
lib/libxml/parser.rb
Parent: Object

Methods

Classes and Modules

Class LibXML::XML::Parser::Context
Class LibXML::XML::Parser::ParseError

Constants

LIBXML_VERSION = rb_str_new2(LIBXML_DOTTED_VERSION)   Constants
VERSION = rb_str_new2(RUBY_LIBXML_VERSION)
VERNUM = INT2NUM(RUBY_LIBXML_VERNUM)

Attributes

error_handler  [R] 

Public Class methods

Dump the parser resource catalogs to stdout.

[Source]

/*
 * call-seq:
 *              XML::Parser.catalog_dump -> true
 * 
 * Dump the parser resource catalogs to stdout.
 */
VALUE
ruby_xml_parser_catalog_dump(VALUE self) {

Remove the specified resource catalog.

[Source]

/*
 * call-seq:
 *              XML::Parser.catalog_remove(catalog) -> true
 * 
 * Remove the specified resource catalog.
 */
VALUE
ruby_xml_parser_catalog_remove(VALUE self, VALUE cat) {

Check LIBXML version matches version the bindings were compiled to. Throws an exception if not.

[Source]

/*
 * call-seq:
 *              XML::Parser.check_lib_versions -> true                                                     
 * 
 * Check LIBXML version matches version the bindings
 * were compiled to. Throws an exception if not.
 */
VALUE
ruby_xml_parser_check_lib_versions(VALUE class) {

Determine whether included-entity debugging is enabled. (Requires Libxml to be compiled with debugging support)

[Source]

/*
 * call-seq:
 *    XML::Parser.debug_entities -> (true|false)
 * 
 * Determine whether included-entity debugging is enabled.
 * (Requires Libxml to be compiled with debugging support)
 */
VALUE
ruby_xml_parser_debug_entities_get(VALUE class) {

Enable or disable included-entity debugging. (Requires Libxml to be compiled with debugging support)

[Source]

/*
 * call-seq:
 *    XML::Parser.debug_entities = true|false
 * 
 * Enable or disable included-entity debugging.
 * (Requires Libxml to be compiled with debugging support)
 */
VALUE
ruby_xml_parser_debug_entities_set(VALUE class, VALUE bool) {

Determine whether parsers use Zlib compression by default (requires libxml to be compiled with Zlib support).

[Source]

/*
 * call-seq:
 *    XML::Parser.default_compression -> (true|false)
 * 
 * Determine whether parsers use Zlib compression by default
 * (requires libxml to be compiled with Zlib support).
 */
VALUE
ruby_xml_parser_default_compression_get(VALUE class) {

Controls whether parsers use Zlib compression by default (requires libxml to be compiled with Zlib support).

[Source]

/*
 * call-seq:
 *    XML::Parser.default_compression = true|false
 * 
 * Controls whether parsers use Zlib compression by default
 * (requires libxml to be compiled with Zlib support).
 */
VALUE
ruby_xml_parser_default_compression_set(VALUE class, VALUE num) {

Determine whether parsers retain whitespace by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_keep_blanks -> (true|false)
 * 
 * Determine whether parsers retain whitespace by default.
 */
VALUE
ruby_xml_parser_default_keep_blanks_get(VALUE class) {

Controls whether parsers retain whitespace by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_keep_blanks = true|false
 * 
 * Controls whether parsers retain whitespace by default.
 */
VALUE
ruby_xml_parser_default_keep_blanks_set(VALUE class, VALUE bool) {

Determine whether parsers retain line-numbers by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_line_numbers -> (true|false)
 * 
 * Determine whether parsers retain line-numbers by default.
 */
VALUE
ruby_xml_parser_default_line_numbers_get(VALUE class) {

Controls whether parsers retain line-numbers by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_line_numbers = true|false
 * 
 * Controls whether parsers retain line-numbers by default.
 */
VALUE
ruby_xml_parser_default_line_numbers_set(VALUE class, VALUE bool) {

Determine whether parsers load external DTDs by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_load_external_dtd -> (true|false)
 * 
 * Determine whether parsers load external DTDs by default.
 */
VALUE
ruby_xml_parser_default_load_external_dtd_get(VALUE class) {

Controls whether parsers load external DTDs by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_load_external_dtd = true|false
 * 
 * Controls whether parsers load external DTDs by default.
 */
VALUE
ruby_xml_parser_default_load_external_dtd_set(VALUE class, VALUE bool) {

Determine whether parsers are pedantic by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_pedantic_parser -> (true|false)
 * 
 * Determine whether parsers are pedantic by default.
 */
VALUE
ruby_xml_parser_default_pedantic_parser_get(VALUE class) {

Controls whether parsers are pedantic by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_pedantic_parser = true|false
 * 
 * Controls whether parsers are pedantic by default.
 */
VALUE
ruby_xml_parser_default_pedantic_parser_set(VALUE class, VALUE bool) {

Determine whether parsers perform inline entity substitution (for external entities) by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_substitute_entities -> (true|false)
 * 
 * Determine whether parsers perform inline entity substitution
 * (for external entities) by default.
 */
VALUE
ruby_xml_parser_default_substitute_entities_get(VALUE class) {

Controls whether parsers perform inline entity substitution (for external entities) by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_substitute_entities = true|false
 * 
 * Controls whether parsers perform inline entity substitution
 * (for external entities) by default.
 */
VALUE
ruby_xml_parser_default_substitute_entities_set(VALUE class, VALUE bool) {

Obtain the default string used by parsers to indent the XML tree for output.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_tree_indent_string -> "string"
 * 
 * Obtain the default string used by parsers to indent the XML tree
 * for output.
 */
VALUE
ruby_xml_parser_default_tree_indent_string_get(VALUE class) {

Set the default string used by parsers to indent the XML tree for output.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_tree_indent_string = "string"
 * 
 * Set the default string used by parsers to indent the XML tree
 * for output.
 */
VALUE
ruby_xml_parser_default_tree_indent_string_set(VALUE class, VALUE string) {

Determine whether parsers perform XML validation by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_validity_checking -> (true|false)
 * 
 * Determine whether parsers perform XML validation by default.
 */
VALUE
ruby_xml_parser_default_validity_checking_get(VALUE class) {

Controls whether parsers perform XML validation by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_validity_checking = true|false
 * 
 * Controls whether parsers perform XML validation by default.
 */
VALUE
ruby_xml_parser_default_validity_checking_set(VALUE class, VALUE bool) {

Determine whether parsers output warnings by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_warnings -> (true|false)
 * 
 * Determine whether parsers output warnings by default.
 */
VALUE
ruby_xml_parser_default_warnings_get(VALUE class) {

Controls whether parsers output warnings by default.

[Source]

/*
 * call-seq:
 *    XML::Parser.default_warnings = true|false
 * 
 * Controls whether parsers output warnings by default.
 */
VALUE
ruby_xml_parser_default_warnings_set(VALUE class, VALUE bool) {

Determine whether libxml regexp automata support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_automata? -> (true|false)
 * 
 * Determine whether libxml regexp automata support is enabled.
 */
VALUE
ruby_xml_parser_enabled_automata_q(VALUE class) {

Determine whether libxml ‘canonical XML’ support is enabled. See "Canonical XML" (www.w3.org/TR/xml-c14n)

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_c14n? -> (true|false)
 * 
 * Determine whether libxml 'canonical XML' support is enabled.
 * See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
 */
VALUE
ruby_xml_parser_enabled_c14n_q(VALUE class) {

Determine whether libxml resource catalog support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_catalog? -> (true|false)                                         
 * 
 * Determine whether libxml resource catalog support is enabled.
 */
VALUE
ruby_xml_parser_enabled_catalog_q(VALUE class) {

Determine whether libxml debugging support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_debug? -> (true|false)  
 * 
 * Determine whether libxml debugging support is enabled.
 */
VALUE
ruby_xml_parser_enabled_debug_q(VALUE class) {

Determine whether libxml docbook support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_docbook? -> (true|false)  
 * 
 * Determine whether libxml docbook support is enabled.
 */
VALUE
ruby_xml_parser_enabled_docbook_q(VALUE class) {

Determine whether libxml ftp client support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_ftp? -> (true|false)  
 * 
 * Determine whether libxml ftp client support is enabled.
 */
VALUE
ruby_xml_parser_enabled_ftp_q(VALUE class) {

Determine whether libxml html support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_html? -> (true|false)  
 * 
 * Determine whether libxml html support is enabled.
 */
VALUE
ruby_xml_parser_enabled_html_q(VALUE class) {

Determine whether libxml http client support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_http? -> (true|false)  
 * 
 * Determine whether libxml http client support is enabled.
 */
VALUE
ruby_xml_parser_enabled_http_q(VALUE class) {

Determine whether libxml iconv support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_iconv? -> (true|false)  
 * 
 * Determine whether libxml iconv support is enabled.
 */
VALUE
ruby_xml_parser_enabled_iconv_q(VALUE class) {

Determine whether libxml memory location debugging support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_memory_debug? -> (true|false)  
 * 
 * Determine whether libxml memory location debugging support
 * is enabled.
 */
VALUE
ruby_xml_parser_enabled_memory_debug_location_q(VALUE class) {

Determine whether libxml regular expression support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_regexp? -> (true|false)  
 * 
 * Determine whether libxml regular expression support is enabled.
 */
VALUE
ruby_xml_parser_enabled_regexp_q(VALUE class) {

Determine whether libxml schema support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_schemas? -> (true|false)  
 * 
 * Determine whether libxml schema support is enabled.
 */
VALUE
ruby_xml_parser_enabled_schemas_q(VALUE class) {

Determine whether libxml thread-safe semantics support is enabled (I think?).

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_thread? -> (true|false)  
 * 
 * Determine whether libxml thread-safe semantics support 
 * is enabled (I think?).
 */
VALUE
ruby_xml_parser_enabled_thread_q(VALUE class) {

Determine whether libxml unicode support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_unicode? -> (true|false)  
 * 
 * Determine whether libxml unicode support is enabled.
 */
VALUE
ruby_xml_parser_enabled_unicode_q(VALUE class) {

Determine whether libxml xinclude support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_xinclude? -> (true|false)  
 * 
 * Determine whether libxml xinclude support is enabled.
 */
VALUE
ruby_xml_parser_enabled_xinclude_q(VALUE class) {

Determine whether libxml xpath support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_xpath? -> (true|false)  
 * 
 * Determine whether libxml xpath support is enabled.
 */
VALUE
ruby_xml_parser_enabled_xpath_q(VALUE class) {

Determine whether libxml xpointer support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_xpointer? -> (true|false)  
 * 
 * Determine whether libxml xpointer support is enabled.
 */
VALUE
ruby_xml_parser_enabled_xpointer_q(VALUE class) {

Determine whether libxml zlib support is enabled.

[Source]

/*
 * call-seq:
 *              XML::Parser.enabled_zlib? -> (true|false)  
 * 
 * Determine whether libxml zlib support is enabled.
 */
VALUE
ruby_xml_parser_enabled_zlib_q(VALUE class) {

Obtains an array of strings representing features supported (and enabled) by the installed libxml.

[Source]

/*
 * call-seq:
 *    XML::Parser.features -> ["feature", ..., "feature"]
 * 
 * Obtains an array of strings representing features supported 
 * (and enabled) by the installed libxml.
 */
VALUE
ruby_xml_parser_features(VALUE class) {

Create a new parser instance that will read the specified file.

[Source]

/*
 * call-seq:
 *    XML::Parser.file -> parser
 * 
 * Create a new parser instance that will read the specified file.
 */
VALUE
ruby_xml_parser_new_file(VALUE class, VALUE filename) {

Determines whether XML output will be indented (using the string supplied to default_indent_tree_string)

[Source]

/*
 * call-seq:
 *    XML::Parser.indent_tree_output -> (true|false)
 * 
 * Determines whether XML output will be indented 
 * (using the string supplied to +default_indent_tree_string+)
 */
VALUE
ruby_xml_parser_indent_tree_output_get(VALUE class) {

Controls whether XML output will be indented (using the string supplied to default_indent_tree_string)

[Source]

/*
 * call-seq:
 *    XML::Parser.indent_tree_output = true|false
 * 
 * Controls whether XML output will be indented 
 * (using the string supplied to +default_indent_tree_string+)
 */
VALUE
ruby_xml_parser_indent_tree_output_set(VALUE class, VALUE bool) {

Create a new parser instance that will read from the specified IO object.

[Source]

/*
 * call-seq:
 *    XML::Parser.io -> parser
 * 
 * Create a new parser instance that will read from the
 * specified IO object.
 */
VALUE
ruby_xml_parser_new_io(VALUE class, VALUE io) {

Perform a parser memory dump (requires memory debugging support in libxml).

[Source]

/*
 * call-seq:
 *    XML::Parser.memory_dump -> (true|false)
 * 
 * Perform a parser memory dump (requires memory debugging 
 * support in libxml).
 */
VALUE
ruby_xml_parser_memory_dump(VALUE self) {

Perform a parser memory dump (requires memory debugging support in libxml).

[Source]

/*
 * call-seq:
 *    XML::Parser.memory_used -> num_bytes
 * 
 * Perform a parser memory dump (requires memory debugging 
 * support in libxml).
 */
VALUE
ruby_xml_parser_memory_used(VALUE self) {

Create a new parser instance with no pre-determined source.

[Source]

/*
 * call-seq:
 *    XML::Parser.new -> parser
 * 
 * Create a new parser instance with no pre-determined source.
 */
VALUE
ruby_xml_parser_new(VALUE class) {

Register the attached block as the handler for parser errors.

Parser.register_error_handler {|msg| <do stuff>} Parser.register_error_handler(lambda {|msg| <do stuff>}) Parser.register_error_handler(nil)

A message describing parse errors is passed to the block. Libxml passes error messages to the handler in parts, one per call. A typical error results in six calls to this proc, with arguments:

  "Entity: line 1: ",
  "parser ",
  "error : ",
  "Opening and ending tag mismatch: foo line 1 and foz\n",
  "<foo><bar/></foz>\n",
  "                 ^\n"

Note that the error handler is shared by all threads.

[Source]

    # File lib/libxml/parser.rb, line 25
25:         def register_error_handler(value = nil, &block)
26:           # Value may be nil or a proc.
27:           tmp = self.error_handler
28:           @error_handler = block_given? ? block : value
29:           tmp
30:         end

Create a new parser instance that will parse the given string.

[Source]

/*
 * call-seq:
 *    XML::Parser.string -> parser
 * 
 * Create a new parser instance that will parse the given
 * string.
 */
VALUE
ruby_xml_parser_new_string(VALUE class, VALUE str) {

[Source]

    # File lib/libxml/parser.rb, line 32
32:         def xml_error_func_handler(msg)
33:           if not self.error_handler
34:             $stderr.puts(msg)
35:           else
36:             self.error_handler.call(msg)
37:           end
38:         end

Public Instance methods

Obtain the XML::Parser::Context associated with this parser.

[Source]

/*
 * call-seq:
 *    parser.context -> context
 * 
 * Obtain the XML::Parser::Context associated with this
 * parser.
 */
VALUE
ruby_xml_parser_context_get(VALUE self) {

Obtain the filename this parser will read from.

[Source]

/*
 * call-seq:
 *    parser.filename -> "filename"
 * 
 * Obtain the filename this parser will read from.
 */
VALUE
ruby_xml_parser_filename_get(VALUE self) {

Set the filename this parser will read from.

[Source]

/*
 * call-seq:
 *    parser.filename = "filename"
 * 
 * Set the filename this parser will read from.
 */
VALUE
ruby_xml_parser_filename_set(VALUE self, VALUE filename) {

Obtain the IO instance this parser works with.

[Source]

/*
 * call-seq:
 *    parser.io -> IO
 * 
 * Obtain the IO instance this parser works with.
 */
VALUE
ruby_xml_parser_io_get(VALUE self, VALUE io) {

Set the IO instance this parser works with.

[Source]

/*
 * call-seq:
 *    parser.io = IO
 * 
 * Set the IO instance this parser works with.
 */
VALUE
ruby_xml_parser_io_set(VALUE self, VALUE io) {

Parse the input XML and create an XML::Document with it’s content. If an error occurs, XML::Parser::ParseError is thrown.

[Source]

/*
 * call-seq:
 *    parser.parse -> document
 * 
 * Parse the input XML and create an XML::Document with
 * it's content. If an error occurs, XML::Parser::ParseError
 * is thrown.
 */
VALUE
ruby_xml_parser_parse(VALUE self) {

Obtain the string this parser works with.

[Source]

/*
 * call-seq:
 *    parser.string -> "string"
 * 
 * Obtain the string this parser works with.
 */
VALUE
ruby_xml_parser_str_get(VALUE self) {

Set the string this parser works with.

[Source]

/*
 * call-seq:
 *    parser.string = "string"
 * 
 * Set the string this parser works with.
 */
VALUE
ruby_xml_parser_str_set(VALUE self, VALUE str) {

[Validate]