.net 接口返回xml字符串

来源:互联网 发布:电脑计算器软件下载 编辑:程序博客网 时间:2024/06/06 07:12
  StringBuilder sb = new StringBuilder();
            string result = string.Empty;
            sb.Append("<?xml version='1.0' encoding='utf-8' ?>");
            sb.Append("<root>");
            try
            {            
              sb.Append("<name>标题</name>");             
            }
            catch (Exception ex)
            {
                sb.Append("");
            }
            sb.Append("</root>");
            string xmlStr =sb.ToString();
            Response.ContentType = "text/xml";
            Response.Charset = "UTF-8";
            Response.Clear();
            Response.Write(xmlStr);
            Response.End(); 
原创粉丝点击