How to add CDATA section in XML file?

Discussion in 'Ruby' started by Re Qu, Jun 26, 2008.

  1. Re Qu

    Re Qu Guest

    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
    --
    Posted via http://www.ruby-forum.com/.
     
    Re Qu, Jun 26, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Davison
    Replies:
    1
    Views:
    636
    Hal Rosser
    Jul 7, 2004
  2. Replies:
    3
    Views:
    801
    Joe Kesselman
    Mar 6, 2006
  3. Dariusz Tomoñ

    deserialize CDATA section in XML

    Dariusz Tomoñ, May 27, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    671
    Dariusz Tomoñ
    May 27, 2007
  4. Pugi!
    Replies:
    2
    Views:
    402
    Julian Turner
    Dec 11, 2006
  5. kampy
    Replies:
    9
    Views:
    374
    Steven D'Aprano
    Oct 19, 2012
Loading...

Share This Page