class XML::Reader
inherits Reference
¶
Class methods¶
.new(str : String, options : XML::ParserOptions = XML::ParserOptions.default)
¶
(str : String, options : XML::ParserOptions = XML::ParserOptions.default)
Creates a new reader from a string.
See XML::ParserOptions.default
for default options.
.new(io : IO, options : XML::ParserOptions = XML::ParserOptions.default)
¶
(io : IO, options : XML::ParserOptions = XML::ParserOptions.default)
Creates a new reader from an IO.
See XML::ParserOptions.default
for default options.
Methods¶
#[](attribute : String) : String
¶
(attribute : String) : String
Gets the attribute content for the attribute given by name.
Raises KeyError
if attribute is not found.
#[]?(attribute : String) : String?
¶
(attribute : String) : String?
Gets the attribute content for the attribute given by name.
Returns nil
if attribute is not found.
#expand : XML::Node
¶
: XML::Node
Expands the node to a XML::Node
that can be searched with XPath etc.
The returned XML::Node
is only valid until the next call to #read
.
Raises a XML::Error
if the node could not be expanded.
#expand? : XML::Node?
¶
: XML::Node?
Expands the node to a XML::Node
that can be searched with XPath etc.
The returned XML::Node
is only valid until the next call to #read
.
Returns nil
if the node could not be expanded.
#move_to_attribute(name : String)
¶
(name : String)
Moves to the XML::Reader::Type::ATTRIBUTE
with the specified name.
#move_to_element
¶
Moves from the XML::Reader::Type::ATTRIBUTE
to its containing XML::Reader::Type::ELEMENT
.
#to_unsafe : LibXML::XMLTextReader
¶
: LibXML::XMLTextReader
Returns a reference to the underlying LibXML::XMLTextReader
.