REXML question

Hello,

I am using REXML to create XML documents but I am facing a problem: I
cannot
add XML childs.

I want to create a parent element with REXML, then add a bunch of XML as
a
children (I already have that XML). I would like to do something like
this:

xml = REXML::Element.new(‘parent’)
xml.add_xml_element(‘value1value2’)

Then xml.to_s would output:
value1value2

I have tried with REXML::Element#add_element, but it adds an extra ‘<’
before
the child:
<value1value2

Am I trying something impossible?

Thank you.

Pau Garcia i Quiles:

xml = REXML::Element.new(‘parent’)
xml.add_xml_element(‘value1value2’)

Then xml.to_s would output:
value1value2

»Element« for creating tags:

parent = REXML::Element.new(‘parent’)

»Document« for XML input:

child = REXML::Document.new(‘value1’)

parent << child
parent.to_s

Kalman