Method: LibXML::XML::Parser.string
- Defined in:
- lib/libxml/parser.rb
.string(string, options = {}) ⇒ Object
call-seq:
XML::Parser.string(string)
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 (|).
83 84 85 86 87 88 89 |
# File 'lib/libxml/parser.rb', line 83 def self.string(string, = {}) context = XML::Parser::Context.string(string) context.base_uri = [:base_uri] if [:base_uri] context.encoding = [:encoding] if [:encoding] context. = [:options] if [:options] self.new(context) end |