Reputation: 67223
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?
Upvotes: 0
Views: 555
Reputation: 990
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();
Upvotes: 1
Reputation: 2678
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.
Upvotes: 1