首页 | 源码下载 | 网站模板 | 网页特效 | 广告代码 | 网页素材 | 字体下载 | 书库 | 站长工具
会员投稿 投稿指南 RSS订阅
当前位置:主页>网络编程>Xml编程>资讯:如何让WebServer返回指定XML内容

如何让WebServer返回指定XML内容

www.jz123.cn  2008-11-20   来源:   中国建站    袁袁整理    我要投递新闻


        public string menuxml;//返回菜单列表的XML字符串

    }

}

/*CheckLogin服务结束*/

 

/*menulist 类开始*/

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using Singcn.SQL;
using System.Data.SqlClient;
using System.IO;
using System.Text;

namespace myfunc.Common
{
    /// <summary>
    /// PubFunc 的摘要说明
    /// </summary>
    public class menulist
    {
        public XmlWriterSettings settings = new XmlWriterSettings();
        public XmlWriter writer = null;
        public string buf = "";
        public SqlShell objShell;
        public SqlCommand objCommand;
        public DataTable objDataTable;

        public menulist(string userid)
        {
            objShell = new SqlShell();
            objCommand = new SqlCommand("select * from qxdmb order by jb,px,qxdm");
            objCommand.CommandType = CommandType.Text;
            objDataTable = objShell.executeDataSet(ref objCommand).Tables[0];

            StringWriter writerstr = new StringWriter();
            settings.Indent = true;
            settings.Encoding = Encoding.GetEncoding("utf-8");
            try
            {
                writer = XmlWriter.Create(writerstr, settings);

                writer.WriteStartDocument();
                writer.WriteStartElement("DSTreeRoot");
                writer.WriteAttributeString("text", "后台管理系统-["+userid+"]");
                writer.WriteAttributeString("treeId", "0000");
                writer.WriteAttributeString("open", "true");

                
                readqxdmb("0");

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
            finally
            {
                if (writer != null)
                    writer.Close();
            }
            buf = writerstr.ToString();
            buf = buf.Replace(@"encoding=""utf-16""", @"encoding=""utf-8""");//在使用StringWriter 作为xml输出时XML自动为“utf-16”,此处用Replace方法处理,如有更好的方法请指教!

上一篇:利用AJAX与数据岛实现无刷新绑定 下一篇:您应该知道的十种 XML 模式

评论总数:1 [ 查看全部 ] 网友评论