首页 > 代码库 > XML 遍历更新重复数据

XML 遍历更新重复数据

string filename = AppDomain.CurrentDomain.BaseDirectory + "DefaultStart.xml";                XmlDocument xmlDoc = new XmlDocument();                xmlDoc.Load(filename);                XmlNode xmlNode = xmlDoc.SelectSingleNode("DocumentElement");                int i = 0;                if (xmlNode.HasChildNodes)                {                    XmlNodeList nodeList = xmlNode.ChildNodes;                    foreach (XmlNode nd in nodeList)                    {                        foreach (XmlNode nd1 in nd)                        {                            if (nd1.Name == "Node")                            {                                nd1.ChildNodes.Item(1).InnerText = dataGridView1.Rows[i].Cells[1].Value.ToString() ;                                nd1.ChildNodes.Item(2).InnerText = dataGridView1.Rows[i].Cells[2].Value.ToString();                                i++;                            }                        }                    }                }                xmlDoc.Save("DefaultStart.xml");//保存

  

XML 遍历更新重复数据