class Nokogiri::XML::Reader
ignored. If a syntax error is encountered during parsing, an exception will be raised.
⚠ libxml2 does not support error recovery in the Reader parser. The RECOVER
ParseOption is
need during a single iteration.
document, you must parse the document again. It may be better to capture all information you
⚠ Nokogiri::XML::Reader#each can only be called once! Once the cursor moves through the entire
end
puts node.name
# node is an instance of Nokogiri::XML::Reader
reader.each do |node|
XML
</x>
<tenderlove:foo awesome=‘true’>snuggles!</tenderlove:foo>
<x xmlns:tenderlove=‘tenderlovemaking.com/’>
reader = Nokogiri::XML::Reader.new <<~XML
Here is an example of usage:
parser, but do not want to write a SAX::Document handler.
The Reader parser might be good for when you need the speed and low memory usage of a SAX
Reader is given an XML document, and yields nodes to an each block.
Nokogiri::XML::Reader parses an XML document similar to the way a cursor would move. The
call Nokogiri::XML::Reader#each to iterate over each node.
The Reader parser allows you to effectively pull parse an XML document. Once instantiated,
##
def self.new(
If present, the block will be passed a Nokogiri::XML::ParseOptions object to modify before
[Yields]
Defaults to +ParseOptions::STRICT+.
- +options:+ (Integer | ParseOptions) Options to control the parser behavior.
- +encoding:+ (String) The name of the encoding of the document.
- +url:+ (String) The base URL of the document.
[Optional Parameters]
- +input+ (String | IO): The \XML document to parse.
[Required Parameters]
Create a new Reader to parse an \XML document.
Reader.new(input, url:, encoding:, options:) { |options| ... } → Reader
Reader.new(input) { |options| ... } → Reader
:call-seq:
def self.new( string_or_io, url_ = nil, encoding_ = nil, options_ = ParseOptions::STRICT, url: url_, encoding: encoding_, options: options_ ) options = Nokogiri::XML::ParseOptions.new(options) if Integer === options yield options if block_given? if string_or_io.respond_to?(:read) return Reader.from_io(string_or_io, url, encoding, options.to_i) end Reader.from_memory(string_or_io, url, encoding, options.to_i) end
def attributes
[Returns]
This is the union of Reader#attribute_hash and Reader#namespaces
Get the attributes and namespaces of the current node as a Hash.
def attributes attribute_hash.merge(namespaces) end
def each
##
def each while (cursor = read) yield cursor end end
def initialize(source, url = nil, encoding = nil) # :nodoc:
def initialize(source, url = nil, encoding = nil) # :nodoc: e = source s = [] ing = encoding