Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
require 'rexml/document' include REXML def index @products = Product.find(:all, :limit => 10) doc = xml_index respond_to do |wants| wants.xml {render :xml => doc} end end def xml_index doc = Document.new products = doc.add_element "Products" @products.each do |product| product = products.add_element "Product" product.add_attributes({"id" => product.id}) descriptions = product.add_element "Descriptions" description = descriptions.add_element "Description" description.text = product.description names = descriptions.add_element "names" names.add_attributes({ "latin_name" => product.latin_name, "english_name" => product.name }) end doc end
This paste will be private.
From the Design Piracy series on my blog: