xml文档读结点值

xml文档读结点值

        private void ReadMutualXML()
        {
            string strFilePath = Application.StartupPath + "\\" + "MutualConfig.xml";
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(strFilePath);
            XmlNode xn = xmlDoc.SelectSingleNode("Mutual");
            foreach (XmlNode cxn in xn.ChildNodes)
            {
                if (cxn.Name.Equals("IP"))
                {
                    m_proxyIP = cxn.InnerText;
                }
                else if (cxn.Name.Equals("Port"))
                {
                    m_proxyPort = Convert.ToInt32(cxn.InnerText);
                }
                else if (cxn.Name.Equals("UserName"))
                {
                    m_username = cxn.InnerText;
                }
                else if (cxn.Name.Equals("Password"))
                {
                    m_password = cxn.InnerText;
                }
            }

        }

你可能感兴趣的:(xml文档读结点值)