猿问

aspx页面怎么输出XML

    Response.ContentType = "text/xml";
        Response.Charset = "GB2312";
        Response.Write("<?xml version=\"1.0\" encoding=\"GB2312\"?>");

依然是按照html的方式输出的啊

aspx怎么输出成xml文件内容


精慕HU
浏览 863回答 2
2回答

慕标5832272

&nbsp;&nbsp;&nbsp;private&nbsp;void&nbsp;ResponseXML(System.Text.StringBuilder&nbsp;xmlnode) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Web.HttpContext.Current.Response.Clear(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Web.HttpContext.Current.Response.ContentType&nbsp;=&nbsp;"Text/XML"; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Web.HttpContext.Current.Response.Expires&nbsp;=&nbsp;0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Web.HttpContext.Current.Response.Cache.SetNoStore(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Web.HttpContext.Current.Response.Write(xmlnode.ToString()); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Web.HttpContext.Current.Response.End(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

慕标琳琳

response.Clear();Response.ContentType&nbsp;=&nbsp;"text/xml";然后拼接xml格式的字符串(数据库端操作);response.write(str);注意删除.aspx页面中的内容,保留头部标记
随时随地看视频慕课网APP
我要回答