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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top