From: Farrel Lifson Date: 2006-03-08T20:44:00+09:00 Subject: Re: [newbie] REXML, each_element and XPath I've done some experimentation and I think the problem is as follows. /doc/element/@attribute is a search for the attribute node, not the element, so using it with doc.each_element isn't strictly 'semantically' correct. If you want to find an element with an attribute you should use the /doc/element[@attribute] xpath string. irb(main):002:0> doc = REXML::Document.new(<" irb(main):004:1" EOF irb(main):005:1> ) irb(main):006:0> doc.each_element("/doc/element[@attribute]"){|n| puts ["attribute"]} value => []