flash读取asps返回xml格式

 protected List<TeamWorkInfos> tList = new List<TeamWorkInfos>();
    protected void Page_Load(object sender, EventArgs e)
    {
        MemberInfo[] mList = GetCacheMembers(1);
        System.Text.StringBuilder xmlnode = new System.Text.StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");

        if (mList == null)
        {
            xmlnode.Append("<data><error>信息读取错误!请您与管理员联系!</error></data>");
            ResponseXML(xmlnode);
            return;
        }
        xmlnode.Append("<persons>");
        if (mList != null)
        {
            foreach (MemberInfo mi in mList)
            {
                xmlnode.Append("<person>");
                xmlnode.AppendFormat("<name>{0}</name>",mi.Nickname);
                if (minfo.Light >= 0 && minfo.Light < 2)
                {
                    xmlnode.AppendFormat("<qq>{0}</qq>", "星光点点");
                }
                else if (minfo.Light >= 2 && minfo.Light < 5)
                {
                    xmlnode.AppendFormat("<qq>{0}</qq>", "星光闪闪");
                }
                else if (minfo.Light >= 5 && minfo.Light < 9)
                {
                    xmlnode.AppendFormat("<qq>{0}</qq>", "星光灿烂");
                }
                else
                {
                    xmlnode.AppendFormat("<qq>{0}</qq>", "星光璀璨");
                }

                xmlnode.AppendFormat("<email>{0}</email>", mi.TeamAge);
                xmlnode.AppendFormat("<pub url=\"{0}\"></pub>", mi.Img);
                xmlnode.AppendFormat("<information>{0}</information>", mi.Selfdesc);
                xmlnode.Append("<pics>");

                tList = GetCacheWorkListByusername(mi.Name);
                foreach (TeamWorkInfos tw in tList)
                {
                    xmlnode.AppendFormat("<pic url=\"{0}\" linkurl=\"{1}\"></pic>", tw.Listpic, tw.Url);
                }
                xmlnode.Append("</pics>");
                xmlnode.AppendFormat("<ziduan1>{0}</ziduan1>", "星光亮度");
                xmlnode.AppendFormat("<ziduan2>{0}</ziduan2>", "星年龄");
                xmlnode.Append("</person>");
            }
        }
        xmlnode.Append("</persons>");

        ResponseXML(xmlnode);
    }

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

posted @ 2011-05-24 15:22  红鲤鱼与驴与绿鲤鱼  阅读(314)  评论(0编辑  收藏  举报