From: Wesley Rishel Date: 2013-01-03T14:26:56+09:00 Subject: rexml.elements.each vs 1.9.3 documentation for same http://www.ruby-doc.org/stdlib-1.9.3/libdoc/rexml/rdoc/REXML/Elements.html#method-i-each includes the following example: doc = Document.new 'sean' doc.root.each {|e|p e} #-> Yields b, c, d, b, c, d elements doc.root.each('b') {|e|p e} #-> Yields b, b elements However when I run it I get the results below. Am I doing something wrong? If not, is the documentation or the code correct? Should I be reporting this somewhere? (My underlying goal is to find an iterator that yields one element at a time from an XPath search, rather than doing the whole search to return a complete array of elements.) Running the example: Sleek:iTunes_Library_Update Wes$ rvm 1.9.3 Sleek:iTunes_Library_Update Wes$ ruby -v ruby 1.9.3p327 (2012-11-10) [x86_64-darwin12.2.0] Sleek:iTunes_Library_Update Wes$ ruby rexml_question.rb "sean" /Users/Wes/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/rexml/parent.rb:40:in `each': wrong number of arguments (1 for 0) (ArgumentError) from rexml_question.rb:10:in `
' Sleek:iTunes_Library_Update Wes$ cat < rexml_question.rb #! /usr/bin/env ruby require "rexml/document" include REXML STDOUT.sync = true doc = Document.new 'sean' doc.root.each {|e|p e} #-> Yields b, c, d, b, c, d elements doc.root.each('b') {|e|p e} #-> Yields b, b elements doc.root.each('child::node()') {|e|p e} #-> Yields , , , , , XPath.each(doc.root, 'child::node()', &block) #-> Yields , , , sean, , , Sleek:iTunes_Library_Update Wes$ -- Posted via http://www.ruby-forum.com/.