I want to replace all my xml attributes with cdata tags, eg:
<Title> test </Title>
<ID> 3939 </ID>
Has cdata tags within them.
What would be a qucik way to do this?
You can use the XCData construct from the Linq-to-XML Library, which should automaticly wrap a CData tag around a string.
Example:
//Assuming your string is called @string
XCData cdata = new XCData(@string);
string cdataString = cdata.ToString();
I dont know how you are reading/writing your XML document
but XmlWriter
class has a .WriteCData(string)
method to be used in the content of a tag.
It's not possible to write CData on an attribute.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.