The example in this article tells the asp.net implementation to write a CDATA method in XmlTextWriter. Share to everyone for your reference, specific as follows:
CDATA can be used to write HTML tags like <br>,<script> or any other markup. You cannot add a simple write writeelementstring to these tags. Converts the character < to >. The following example shows the use of writeelementstring to write a CDATA region.
Add a reference first
In a program like this to write
void Page_Load (object sender, System.EventArgs e) {
XmlTextWriter xmlWriter = new XmlTextWriter (Server.MapPath (" Xmltextwriterwithwritecdata.xml "), null);
Automatic formatting of xml
xmlwriter.formatting = formatting.indented;
Writes the root element
xmlwriter.writestartelement ("CategoryList");
Writes the first element
xmlwriter.writestartelement ("Category");
Adding elements to the category element
xmlwriter.writeelementstring ("Maincategory", "<br>");
Write CDATA
xmlwriter.writecdata ("<br>");
Write End character
xmlwriter.writeendelement ();
Close writer
xmlwriter.close ();
Response.Write ("Xml written");
More interested readers of asp.net related content can view the site topics: "asp.net operation XML Skills summary", "asp.net file Operation skills Summary", "ASP.net Ajax Skills Summary topic" and "asp.net cache operation skills Summary."
I hope this article will help you to ASP.net program design.