日期:2014-05-20  浏览次数:21039 次

StringBuilder生成HTML的问题
小弟我做的一个项目,需要在代码中生成HTML

我是这样的
sb.Append( " <html   xmlns=\ "http://www.w3.org/1999/xhtml\ "> ");   //   sb   is   an   instance   of   the   StringBuilder   class

the   output   I   expected   is   <html   xmlns= "http://www.w3.org/1999/xhtml ">
but   the   output   was   <html   xmlns=\ "http://www.w3.org/1999/xhtml\ ">

I   also   tried   "@ "   character.   but   it   doesn 't   work   either.
Is   there   some   compromised   way   to   handle?     i   don 't   like   " ' ".

any   suggestion   will   be   really   appreciated

------解决方案--------------------
我这里测试没问题
Web:
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append( " <html xmlns=\ "http://www.w3.org/1999/xhtml\ "> ");
Response.Write(sb.ToString());

ConsoleApplication:
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append( " <html xmlns=\ "http://www.w3.org/1999/xhtml\ "> ");
System.Console.WriteLine(sb.ToString());
System.Console.ReadLine();


------解决方案--------------------
sb.Append( " <html xmlns=\ "http://www.w3.org/1999/xhtml\ "> ");
输出正常呀。。
------解决方案--------------------
你看见的输出是监视窗口的输出么?那个无所谓了,因为监视字符串总要上引号,那个是为了避免歧义, 关键是程序里的输出。 应该是没有问题的。