tags:

views:

412

answers:

3

I generate a XMLDocument based on a dataset by binding the dataset to the XMLDocument object and then display it to user in vb.net. I have a requirement in which certain tags to contain cdata sections rather than text value. After generating the XMLDocument how to change only certain tag to cdata section and keeping all else as it is? Or is there a way to modify while binding itself?

A: 

There is no difference between a text section and a CDATA, except how characters are quoted inside them. The parser that consumes the data won't see a difference. Are you sure you need to create a CDATA section?

Ned Batchelder
A: 

Actually the reason we are going with CDATA section is that the output text contain certain HTML format strings in it. When it is took as a plain text it will be taken by parser as a XMl element. For eg.

I need to display as

"<tag><![CDATA[Sample HTML tag <head> ]]> </tag>"
blntechie
+1  A: 

You could use the "XmlDocument.CreateCDataSection(string)" method. First search each text string for "<" or ">" characters -- or for a full tag "" if known -- then use the appropriate method to output the data.

DreadPirateShawn