使用 aspx 页面返回 xml 格式的值时,需要注意写法

来源:互联网 发布:美萍软件进销存 编辑:程序博客网 时间:2024/06/05 02:54

解决了,是1楼说的方法,不能写成

context.Response.ContentType = "xml";

必须要是

context.Response.ContentType = "text/xml";

就OK了~

 

实例:

 

  Response.ContentType = "text/xml";
            Page.Response.Write("<?xml version=/"1.0/" encoding=/"UTF-8/"?>");
            Page.Response.Write("<data>");
            Page.Response.Write("<pets>");
            Page.Response.Write("<pet>猫</pet>");
            Page.Response.Write("<pet>狗</pet>");
            Page.Response.Write("<pet>鱼</pet>");
            Page.Response.Write("</pets>");
            Page.Response.Write("</data>");

原创粉丝点击