Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Forked from anonymous/gist:426022
Created June 4, 2010 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/426028 to your computer and use it in GitHub Desktop.
Save tenderlove/426028 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 << 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