单独建一个xml文件来存取多个不同的ip
198.168.1.25
198.168.1.26
198.168.1.27
..........怎样在页面中读取ip进行逐个进行判断,
if(ip==IP)

解决方案 »

  1.   

    读取到xml文件的ip,逐个和获取的IP判断
      

  2.   

                XmlReader xr = XmlReader.Create(@"C:\datas.xml");
                while (xr.Read())
                {
                    if (xr.NodeType == XmlNodeType.Text)
                    {
                        Console.WriteLine(xr.Value);
                    }
                }
                Console.ReadKey();XML文件是:
    <?xml version="1.0" encoding="UTF-8"?>
    <IPs>
    <IP>1</IP>
    <IP>2</IP>
    <IP>3</IP>
    </IPs> 类似的试试就差不多了
      

  3.   

      XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(Server .MapPath("~/XMLip.xml"));
                XmlNodeList nodelist = xmldoc.SelectNodes("/ips/ip");
                foreach (XmlNode node in nodelist)
                {
                    Response.Write(node.InnerText );
                }
      

  4.   

    XML文件格式对么?public static string Read(string path, string node, string attribute)
            {
                string value = "";
                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(path);
                    XmlNode xn = doc.SelectSingleNode(node);
                    value = (attribute.Equals("") ? xn.InnerText : xn.Attributes[attribute].Value);
                }
                catch { }
                return value;
            }
      

  5.   

    用xml读取对象读取然后遍历,或者将xml读到dataset中,然后再遍历