How to change a text value tag to a cdata section

I am generating an XMLDocument from a dataset by binding the dataset to an XMLDocument object and then displaying it to the user on vb.net. I have a requirement that certain tags contain cdata sections and not a text value. After generating the XMLDocument, how do I change only a specific tag in the cdata section and keep everything else as it is? Or is there a way to change when binding yourself?

0


source to share


3 answers


You can use XmlDocument.CreateCDataSection (string) method. First, find each text line for "<" or ">" - or for the complete tag "" if known - then use the appropriate method to output the data.



+1


source


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



0


source


Actually the reason we go with the CDATA section is because the output text contains certain HTML format strings. When taken as plain text, it will be treated as an XMl element by the parser. For example,

I need to display as

"<tag><![CDATA[Sample HTML tag <head> ]]> </tag>"

      

0


source







All Articles