W3cubDocs

/Crystal

struct XML::Reader

Defined in:

xml/reader.cr
xml/reader/type.cr

Constructors

Instance Method Summary

Constructor Detail

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

Creates a new reader from a string.

See XML::ParserOptions.default for default options.

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

Creates a new reader from an IO.

See XML::ParserOptions.default for default options.

Instance Method Detail

def [](attribute : String) : StringSource

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

def []?(attribute : String) : String?Source

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

def attributes_countSource

Returns attribute count of the node.

def depthSource

Returns the current nesting depth of the reader.

def empty_element?Source

Checks if the node is an empty element.

def expand : XML::NodeSource

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.

def expand? : XML::Node?Source

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.

def has_attributes?Source

Checks if the node has any attributes.

def move_to_attribute(name : String)Source

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

def move_to_elementSource

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

def move_to_first_attributeSource

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

def move_to_next_attributeSource

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

def nameSource

Returns the name of the node.

def nextSource

Moves the reader to the next node while skipping subtrees.

def next_siblingSource

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

def node_type : XML::Reader::TypeSource

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

def readSource

Moves the reader to the next node.

def read_inner_xmlSource

Returns the node's XML content including subtrees.

def read_outer_xmlSource

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

def to_unsafe : LibXML::XMLTextReaderSource

Returns a reference to the underlying LibXML::XMLTextReader.

def valueSource

Returns the text content of the node.

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/XML/Reader.html