From: Roger Braun Date: 2011-04-01T07:35:14+09:00 Subject: Re: Simple array.each do |x| question Hi 2011/4/1 Kyle X. : > Hello, I am new to ruby and cannot understand why this code is not > working: > > direction = doc.elements.each("doc:iso_10303_28/uos/IfcCartesianPoint") > { |element| puts element.attributes["id"] } > # this produces [i1586,i1667,i1915,i2041,i2160] > result = [] > direction.each do |z| >  n = direction[z].attribute["id"] >  result << n > end The variable z does not contain an index but the object you need. Try direction.each do |z| n = z.attribute["id"] result << n end This should also work: result = direction.map{|z| z.attribute["id"]} -- Roger Braun rbraun.net | humoralpathologie.de