Method: LibXML::XML::Parser.string
- Defined in:
- lib/libxml/parser.rb
.string(string, base_uri: nil, encoding: nil, options: nil) ⇒ 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.
Parameters:
string - The string to parse
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. Multiple options can be combined
by using Bitwise OR (|).
85 86 87 88 89 90 91 |
# File 'lib/libxml/parser.rb', line 85 def self.string(string, base_uri: nil, encoding: nil, options: nil) context = XML::Parser::Context.string(string) context.base_uri = base_uri if base_uri context.encoding = encoding if encoding context. = if self.new(context) end |