From: Adam Lorens Date: 2009-07-22T17:43:09+09:00 Subject: Re: Parsing XML in Ruby Bertram Scharpf wrote: > Hi, > > Am Dienstag, 21. Jul 2009, 23:39:14 +0900 schrieb Adam Giewond: >> I'm new in this forum, so i'm be very gratefull, you won't be angry if I >> ask some stupid question. My today work is: "Parsing XML in Ruby", XML >> is in attachment. I've never done it, so please help me:) > > REXML belongs to the Ruby standard library. > > http://www.xml.com/pub/a/2005/11/09/rexml-processing-xml-in-ruby.html > > Bertram ok thanks very much, I decided to use REXML, but i have problem with this examples. My XML file is more complicated so I want require to simplifi code. I'm still using this example (movies.xml) becouse it's less complicated. I don't want refer to every position (like title, year etc) but to all. My proposition: #!/usr/bin/ruby -w require 'rexml/document' include REXML xmlfile = File.new("movies.xml") xmldoc = Document.new(xmlfile) # Now get the root element root = xmldoc.root puts "Root element : " + root.attributes["shelf"] # This will output all the movie titles. xmldoc.elements.each("collection"){ |e| puts e.attributes["title"] } doesn't work. I'll be very gratefull when someone explain where is mistake... regards adam -- Posted via http://www.ruby-forum.com/.