All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASP.NET技巧:使用ASPX输出XML应注意的问题_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/8 7:02:05 Browse times: 324 Comment times: 0

ASP.NET技巧:使用ASPX输出XML应注意的问题_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

ASP.NET技巧:使用ASPX输出XML应注意的问题_[Asp.Net教程] Ajax应用程序中服务器端如果使用ASPX返回XML格式数据,一般将VS生成的HTML字符先清除,代码文件中直接使用Response.Write输出XML字符串。

  需要注意的是要设置Response的相应属性客户端才能正确解析字符串。

  首先要设置ContentType 属性:

Response.ContentType = "text/xml";

  如果xml字符串中包含中文则还要设置Charset属性:

Response.Charset = "GB2312";

  然后按照XML文件的格式输出内容:

Response.Write("");

  今天就是因为这个Charset让我郁闷了好久,因为XML字符中中包含中文字符而又没有设置Charset,因此XMLHttpRequest.responseXML总是null,查了半天资料终于恍然大悟。

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.