Skip to content

Instantly share code, notes, and snippets.

Created June 4, 2010 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/426022 to your computer and use it in GitHub Desktop.
Save anonymous/426022 to your computer and use it in GitHub Desktop.
require 'nokogiri'
doc = Nokogiri::XML(open("news.rss"))
content_tag = Nokogiri::XML::Node.new "content", doc
content_tag.content = doc.create_cdata("<<<<")
doc.at("//item/description").add_next_sibling(content_tag)
doc.to_xml # CDATA gets converted to entities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment