4

I have a Google merchant centre XML script which is printing additional white space within every element and I can't seem to get rid of it

I've simplified the script below to demonstrate what I'm after. Current script:

xml.instruct!
 xml.feed 'xmlns' => 'http://www.w3.org/2005/Atom', 'xmlns:g' => 'http://base.google.com/ns/1.0' do
 @site.products.find(:all).each do |product|
  xml.entry do
    xml.g :image_link do xml.text!("http://www.mysite.com/{product.picture}"); end
  end
 end
end

Outputs:

<feed>
  <entry>
    <g:image_link>
  http://www.mysite.com/resources/images/pic.jpg
</g:image_link>
</entry>
</feed>

Notice that the image's url is on the next line and indented which won't work. What I need is:

<feed>
  <entry>
    <g:image_link>http://www.mysite.com/resources/images/pic.jpg</g:image_link>
  </entry>
</feed>

How can I resolve this please?

moztech
  • 430
  • 2
  • 4
  • 14

1 Answers1

4

To help anyone else with this issue in the future, how I finally resolved it was by changing the detail lines

From:

xml.g :image_link do xml.text!("http://www.mysite.com/{product.picture}"); end

To:

xml.g :image_link, "http://www.mysite.com#{product.picture}"

With thanks to: http://codalicious.wordpress.com/2010/06/16/product-rss-feed-for-google-base/

moztech
  • 430
  • 2
  • 4
  • 14