zoukankan      html  css  js  c++  java
  • 读取XML类

    根据返回的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类

  • 相关阅读:
    uniApp 实现微信小程序和app视频播放flv格式视频监控
    uniapp 给子组件传值不及时显示
    uni-app 中$refs 在app中无法使用
    使用甘特图
    背景图片加蒙版,里面内容不受影响
    MyBatis 多对一操作
    在Maven项目中使用lombok
    MyBatis使用分页
    Log4j打印日志
    paramiko 下载文件
  • 原文地址:https://www.cnblogs.com/hankstar/p/1460143.html
Copyright © 2011-2022 走看看