From: Peter Szinek Date: 2006-12-21T17:05:53+09:00 Subject: Re: Creating New Objects from REXML::Elements eddieroger wrote: > Hello group, > > I'm new to using REXML to parse documents, but quickly getting the hang > of it. Something, however, is giving me a little trouble, so I could > use some help. I'm trying to create a new object, specifically a Movie > from elements in Delicious Library's XML data file (a Mac program, > found at http://www.delicious-monster.com). Basically, the XML file > stores the good stuff in tag attributes, and I'd rather make a new > objects from the attributes. I can pull the attributes, and puts proves > I'm pulling right, but when I try to push my new objects into an array, > the class identifies itself as an REXML::Element instead of a Movie. > > This is the method that puts the new Movies into the array. > def get_movies > temp = @library.root > temp.elements.each('items/movie') { |movie| > @movies.push(Movie.new(movie.attributes['uuid'], > movie.attributes['fullTitle'], movie.attributes['asin'], > movie.attributes['mpaarating'], movie.attributes['minutes'], > movie.attributes['published'], movie.attributes['price'])) > puts movie.attributes['fullTitle'] > } > end Can you send the full code? Are you sure that e.g. Movie.new does not return a REXML::Element for example? Anyway, I can not really figure this out without seeing the full code. Cheers, Peter __ http://www.rubyrailways.com