From: Kouhei Sutou Date: 2003-01-10T01:16:31+09:00 Subject: Re: REXML and XPath Confusion REXML::Attributes#[] returns not a REXML::Attribute object but a String object. From: Mark Probert Subject: REXML and XPath Confusion Date: Fri, 10 Jan 2003 00:47:30 +0900 Message-ID: <5.1.0.14.2.20030109104105.00b2e7d0@zcard04k.ca.nortel.com> > $ 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 "panel class --> [#{panel.class}]" > } > 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 "name class --> [#{name.class}]" > puts (panels.include?(name)) ? "included" : "not found" > } > } Regards, ====================== Kouhei Sutou kou@cneti.net