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?

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.