hankstar

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

根据返回的XML语句 取值

 

 

 

        XmlDocument doc = new XmlDocument();

        try
        {
            doc.Load(Server.MapPath("XML1_1.xml"));

            XmlNodeList nodes = doc.SelectSingleNode("delivers").ChildNodes;

            int num = 0;
            num = Convert.ToInt32(nodes[0].InnerText.ToString());

            string id = string.Empty;
            string content = string.Empty;
            string phone = string.Empty;

            if (num > 0)
            {
                for (int i = 1; i < nodes.Count; i++)
                {
                    XmlNodeList nodess = nodes.Item(i).ChildNodes;

                    id = string.Empty;
                    content = phone = string.Empty;

                    phone = ((XmlElement)nodess[0]).FirstChild.Value;
                    id = ((XmlElement)nodess[1]).FirstChild.Value;
                    content = ((XmlElement)nodess[2]).FirstChild.Value;

                    Response.Write("<script>alert('" + phone + "\\n" + id + "\\n" + content + "\\n')</script>");

                }
            }
            else
            {
                Response.Write("0");
            }
        }
        catch
        {
            Response.Write("104");
        }
   

 

精致的代码,精致的生活

例子:XML类

 

posted on 2009-05-19 13:53  熊的世界  阅读(294)  评论(0编辑  收藏  举报