How to write my string "<" in XML format
-
Hi all as is known to all,the char '<','>','&' is XML format. but when i want to write a string that contain a '<' or '>' or '&' in a XML,i could replace it such as :
string XMLstring = x[y].ToString(); XMLstring = XMLstring.Trim(); XMLstring = XMLstring.Replace("&", "&"); XMLstring = XMLstring.Replace(">", ">"); XMLstring = XMLstring.Replace("<", "<"); excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" + "<Data ss:Type=\"String\">"); excelDoc.Write(XMLstring);
but i failed :excelDoc.Write("<Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">");
what should i do ? Thanks! -
Hi all as is known to all,the char '<','>','&' is XML format. but when i want to write a string that contain a '<' or '>' or '&' in a XML,i could replace it such as :
string XMLstring = x[y].ToString(); XMLstring = XMLstring.Trim(); XMLstring = XMLstring.Replace("&", "&"); XMLstring = XMLstring.Replace(">", ">"); XMLstring = XMLstring.Replace("<", "<"); excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" + "<Data ss:Type=\"String\">"); excelDoc.Write(XMLstring);
but i failed :excelDoc.Write("<Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">");
what should i do ? Thanks!That's not a good idea. Put the text in a CDATA[^] section.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
Hi all as is known to all,the char '<','>','&' is XML format. but when i want to write a string that contain a '<' or '>' or '&' in a XML,i could replace it such as :
string XMLstring = x[y].ToString(); XMLstring = XMLstring.Trim(); XMLstring = XMLstring.Replace("&", "&"); XMLstring = XMLstring.Replace(">", ">"); XMLstring = XMLstring.Replace("<", "<"); excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" + "<Data ss:Type=\"String\">"); excelDoc.Write(XMLstring);
but i failed :excelDoc.Write("<Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">");
what should i do ? Thanks!If excelDoc is an XmlDocument it'll handle all that for you.