From: "Thibaut Barrère" Date: 2006-03-08T19:08:40+09:00 Subject: [newbie] REXML, each_element and XPath Hi! while playing with REXML I try to use each_element with an x-path expression involving an attribute (doc/element/@attribute) but can't get it to work this way (it works perfectly fine with both XPath.each and each_element applied on doc/element without @attribute). here's my test suite to illustrate this, is there some obvious mistake that I cannot see ? I've read in older posts that each_element did not recurse, would it be the explanation ? any insight most welcome! kind regards Thibaut ============ require "test/unit" require "rexml/document" include REXML class XmlTests < Test::Unit::TestCase # fail def test_each_element_with_attribute count = 0 @doc.each_element("doc/element/@attribute") { |n| count = count+1 } assert_equal 1,count end # pass def test_each_element_without_attribute count = 0 @doc.each_element("doc/element") { |n| count = count+1 } assert_equal 1,count end # pass def test_xpath count = 0 XPath.each(@doc,"doc/element/@attribute") { |n| count = count+1 } assert_equal 1,count end def setup @doc = Document.new(< EOF ) end end