On Wed, 13 Dec 2006 08:27:19 -0000, Thomas Mueller  
<thomasmueller76 / googlemail.com> wrote:

> Hi,
>
> I need to add a CDATA element to an XML document.
>
> The libxml API documentation says that I can use Node.new_cdata, but
> this doesn't work here for some reason (Ubuntu with libxml-ruby
> 0.3.4-4): "undefined method 'new_cdata' for XML::Node::Class"
>

Wow, that's a fairly old version you have there :)

> How can I create a CDATA element using libxml?
>
> I was looking at REXML but didn't like the API at all and would very
> much prefer using libxml.
>

You just need to upgrade your libxml-ruby installation (or pester ubuntu  
to upgrade theirs). new_cdata was added in the 0.3.8 branch:

require_gem 'libxml-ruby', '>= 0.3.8'
# => true

require 'xml/libxml'
# => true

XML::Node.new_cdata('cdata foo')
# => <![CDATA[cdata foo]]>


-- 
Ross Bamford - rosco / roscopeco.remove.co.uk