require "amrita/template" require "rexml/document" include Amrita doc = REXML::Document.new < Ruby In A Nutshell Yukihiro Matsumoto David L. Reynolds Programming Ruby David Thomas Andrew Hunt The Ruby Way Hal Fulton END table = doc.elements.to_a("booklist/book").collect do |book| { :title=>book.elements['title'], :authors=>book.elements.to_a('author').collect do |a| { :name=>a } end, #:isbn=>book.attributes['isbn'] :isbn=>e(:a, :href=>"http://www.amazon.com/exec/obidos/ASIN/#{book.attributes['isbn']}") { book.attributes['isbn'] } } end data = { :table1=>table } html_tmpl = TemplateText.new < titleauthorISBN
END html_tmpl.prettyprint = true #html_tmpl.set_hint(HtmlCompiler::AnyData.new) html_tmpl.expand(STDOUT, data)