From: eddieroger Date: 2006-12-21T23:25:10+09:00 Subject: Re: Creating New Objects from REXML::Elements Here is the full Ruby code: require 'rexml/document' include REXML class DeliciousLibrary #usual_path is the path of the DL XML file (until v2). Unless this script is on a server, this works. @@usual_path = "#{ENV['HOME']}/Library/Application Support/Delicious Library/Library Media Data.xml" @@medium_covers = "#{ENV['HOME']}/Library/Application Support/Delicious Library/Medium Covers/" #requires UUID for identification def initialize(file = @@usual_path) @library = Document.new(File.new(file)) @movies = Array.new end def get_library_as_xml @library.root end def get_movies temp = @library.root temp.elements.each('items/movie') { |movie| @movies.push(Movie.new(movie.attributes['uuid'].to_str, movie.attributes['fullTitle'], movie.attributes['asin'], movie.attributes['mpaarating'], movie.attributes['minutes'], movie.attributes['published'], movie.attributes['price'])) puts movie.attributes['fullTitle'] } end def get_shelves @library.root.elements['items/shelves'] end end class Movie #Some Supplimental Classes def initialize(uuid, fullTitle, asin, mpaarating, minutes, published, price) @uuid = uuid @fullTitle = fullTitle @asin = asin @mpaarating = mpaarating @minutes = minutes @published = published @price = price end attr_reader :uuid, :fullTitle, :asin, :mpaarating, :minutes, :published, :price end The XML file is about 7000 lines long, os here's a snippet. i don't think you really want 7000 lines of code listed anyway. ... Thanks for the help. Bob Hutchison wrote: > On 21-Dec-06, at 3:05 AM, Peter Szinek wrote: > > > 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. > > > > > And the XML as well. > > Cheers, > Bob > > > Cheers, > > Peter > > ---- > Bob Hutchison -- blogs at hutch/> > Recursive Design Inc. -- > Raconteur -- > xampl for Ruby --