Skip to content

class XML::Reader
inherits Reference

Class methods

.new(str : String, options : XML::ParserOptions = XML::ParserOptions.default)

Creates a new reader from a string.

See XML::ParserOptions.default for default options.

View source

.new(io : IO, options : XML::ParserOptions = XML::ParserOptions.default)

Creates a new reader from an IO.

See XML::ParserOptions.default for default options.

View source

Methods

#[](attribute : String) : String

Gets the attribute content for the attribute given by name. Raises KeyError if attribute is not found.

View source

#[]?(attribute : String) : String?

Gets the attribute content for the attribute given by name. Returns nil if attribute is not found.

View source

#attributes_count

Returns attribute count of the node.

View source

#depth

Returns the current nesting depth of the reader.

View source

#empty_element?

Checks if the node is an empty element.

View source

#expand : 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.

View source

#expand? : 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.

View source

#has_attributes?

Checks if the node has any attributes.

View source

#move_to_attribute(name : String)

Moves to the XML::Reader::Type::ATTRIBUTE with the specified name.

View source

#move_to_element

Moves from the XML::Reader::Type::ATTRIBUTE to its containing XML::Reader::Type::ELEMENT.

View source

#move_to_first_attribute

Moves to the first XML::Reader::Type::ATTRIBUTE of the node.

View source

#move_to_next_attribute

Moves to the next XML::Reader::Type::ATTRIBUTE of the node.

View source

#name

Returns the name of the node.

View source

#next

Moves the reader to the next node while skipping subtrees.

View source

#next_sibling

Moves the reader to the next sibling node while skipping subtrees.

View source

#node_type : XML::Reader::Type

Returns the XML::Reader::Type of the node.

View source

#read

Moves the reader to the next node.

View source

#read_inner_xml

Returns the node's XML content including subtrees.

View source

#read_outer_xml

Returns the XML for the node and its content including subtrees.

View source

#to_unsafe : LibXML::XMLTextReader

Returns a reference to the underlying LibXML::XMLTextReader.

View source

#value

Returns the text content of the node.

View source