Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)delvpublished in(发表于) 2014/1/8 7:02:05 ASP.NET技巧:使用ASPX输出XML应注意的问题_[Asp.Net教程]
需要注意的是要设置Response的相应属性客户端才能正确解析字符串。
首先要设置ContentType 属性:
Response.ContentType = "text/xml";
如果xml字符串中包含中文则还要设置Charset属性:
Response.Charset = "GB2312"; 然后按照XML文件的格式输出内容:
Response.Write(""); 今天就是因为这个Charset让我郁闷了好久,因为XML字符中中包含中文字符而又没有设置Charset,因此XMLHttpRequest.responseXML总是null,查了半天资料终于恍然大悟。
来源:网络
赞