Search code examples
c#xmlxmldocument

updating CDATA in xml


i have xml file which contains CDATA

i need to update the CDATA as like in this example.

i am modifying "span" here

<elements>
    <![CDATA[-div[id|dir|class|align|style],-span[class|align]]]>
  </elements>

should be updated as

<elements>
    <![CDATA[-div[id|dir|class|align|style],-span[class|align|style]]]>
  </elements>

i am using framework 2.0.. how to do this using xmldocument.

thank you


Solution

  • You will need to extract the cdata as a regular string, then adjust it using normal string operations (or a regex) before re-inserting as cdata. That is the nature of cdata sections.