I'm trying to include a URL to an image in an XML file, and the ampersands in the URL query string are getting stripped out:
bgdoc.xpath('//Master').each do |elem|
  part = elem.xpath('Part').inner_text
  image = imagehash[part]
  image = "" if image.blank?
  elem.xpath('Image').first.content = "<![CDATA[#{image}]]>"
  puts elem.xpath('Image').first.content
end
bgdoc is getting written out with the help of Builder later on. But not the individual elements, it's getting inserted all at once. That makes it a different case than a similar question posted on SO.