Skip to content

Instantly share code, notes, and snippets.

@robc
Created January 27, 2009 01:01
Show Gist options
  • Save robc/53094 to your computer and use it in GitHub Desktop.
Save robc/53094 to your computer and use it in GitHub Desktop.
# Using this code, I can build the XML document, but there's garbage at the end of the document (see the notes below).
# I'm not sure if there's any extra configuration needed, but I can't use 'render :xml' to render it (I think it's related to the way Builder actually works)
xml_markup = Builder::XmlMarkup.new
xml_markup.instruct!
xml_markup.products do
@products.each do |product|
@product_commission_url = "#{network.full_base_url}t2/#{network.id}/@@SIDEID@@/#{creative_id}/@@OPT?link=#{CGI.escape(product.url)}"
xml_markup.product do
xml_markup.url(@product_commission_url)
xml_markup.id(product.id)
xml_markup.name(product.name)
xml_markup.recommended_retail_price(product.recommended_retail_price)
xml_markup.sale_price(product.sale_price)
xml_markup.description(product.description)
xml_markup.recommended_category(product.recommended_category)
xml_markup.image_url(product.image_url)
xml_markup.upload_date(product.upload_date)
xml_markup.postage(product.postage)
xml_markup.brand(product.brand)
xml_markup.availability(product.availability)
xml_markup.thumbnail(product.thumbnail)
xml_markup.thumbnail_width(product.thumbnail_width)
xml_markup.thumbnail_height(product.thumbnail_height)
end
end
end
# If I do not include the '__send(:to_s)' on the render, I get nothing.
# If I do include it, I get a malformed "<__send:to_s/>" tag at the end of the document...
render :text => xml_markup.__send(:to_s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment