From: James Britt Date: 2006-05-14T03:40:59+09:00 Subject: Re: list folder content from win directory -> xml output Sergey Volkov wrote: > just to continue after previous start :) : > # > open( "all_files.xml", "w" ){ |out| > out.puts "" > Dir["**/*"].each{ |f| out.puts " #{f}" } > out.puts "" > } > # > this code outputs list of all files in output file in xml format: > 'all_files.xml'; You may need to replace special characters class String # For demo purposes only. def xscape self.gsub( '&', '&').gsub( '<', '< ) end end And then call Dir["**/*"].each{ |f| out.puts " #{f.xscape}" } For extra fun consider adding file attributes as element attributes: Dir["**/*"].each{ |f| fl = File.new(f) mtime = " mtime='#{fl.mtime.to_s.xscape}' " ctime = " ctime='#{fl.ctime.to_s.xscape}' " out.puts " #{f.xscape}" } More or less. > > resources: you can start with > http://www.rubycentral.com/book/ > http://www.ruby-lang.org/en/ and http://www.ruby-doc.org There may be some useful stuff at http://www.rubyxml.com as well. -- James Britt http://www.ruby-doc.org - Ruby Help & Documentation http://www.artima.com/rubycs/ - The Journal By & For Rubyists http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys http://www.30secondrule.com - Building Better Tools