How to add CDATA section in XML file?

R

Re Qu

Dear all,

I am fairly new to ruby and am trying to create a CDATA section in an
XML file. Here is an example of what I am trying to produce:

<Data>
<![CDATA[<TestFlowModel
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
namespace="TestFlow1"
xmlns="http://schemas.xx.com/testtool/TestFlowModel">

<TestFlow definitionid="ad000000-0000-0000-0000-100000000001"
name="APPLY_SEQUENCE_INVALID_DATA" startstep="Sequence1.Section1.Step1">
<Tests>
<Test id="00000000-0000-0000-0000-100000000001" name="Test1" >
<TestElements>
<Expectation id="00000000-0000-0000-0000-200000000001"/>
<Expectation id="00000000-0000-0000-0000-200000000002"/>
<Input id="00000000-0000-0000-0000-300000000001"/>
<Input id="00000000-0000-0000-0000-300000000002"/>
</TestElements>
<Navigation>
<Action id="00000000-0000-0000-0000-400000000001"/>
</Navigation>
</Test>
</Tests>
</TestFlow>
</TestFlowModel>]]>
</Data>


I have been able to add the section using CData.new. But I get an error
when trying to add the remaining XML. I thought this code might work:

$xmldata = e11 = Element.new("TestFlowModel")
cdata = CData.new($xmldata)

But unfortunately this gives me a "Object#type is deprecated; use
Object#class" error.

Any ideas on how I can achieve this? Thank you in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top