From: Mark Probert Date: 2003-01-10T00:47:30+09:00 Subject: REXML and XPath Confusion Rubyists, I am confused! (Nothing unusual there! :-) Using XPath.match, I get an array of attributes. When I try to match against this array, with what seems to be the same name, it doesn't match. Any ideas? $ cat test.xml
$ cat test.rb require "rexml/xpath" require "rexml/document" include REXML doc = Document.new File.new( "test.xml" ) panels = XPath.match( doc, "//panel/attribute::name" ) panels.each { |panel| puts "panel --> [#{panel}]" } puts "-----" doc.elements.each("doc/section") { |sect| puts "sect --> #{sect.attributes["name"]}" sect.elements.each("panel") { |panel| name = panel.attributes["name"] puts "panel --> [#{name}]" puts (panels.include?(name)) ? "included" : "not found" } } $ ruby test.rb panel --> [overview] panel --> [stuff] ----- sect --> intro panel --> [overview] not found panel --> [stuff] not found sect --> foo sect --> bar Regards, -mark.