XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(Application.StartupPath+"\\database\\xmlData.xml");
    XmlNodeList nodeList = xmlDoc.SelectSingleNode("datapath").ChildNodes;
    foreach(XmlNode xn in nodeList)
    {
     XmlElement xe=(XmlElement)xn;
     if (xe.Name == "servername")
     {
      this.txtServerName.Text=xe.InnerText;
     }
     else if (xe.Name =="dbname")
     {
     
      this.txtdbname.Text=xe.InnerText ;
     }
     else if (xe.Name =="username")
     {
      this.txtusername.Text = xe.InnerText;
     }
     else if(xe.Name =="password")
     {
      this.txtpwd.Text=xe.InnerText;
     }
    }

相关文章: