private void SavePreference() { XmlElement pref = _project.Preference; foreach (XmlNode node in pref.SelectNodes("Property[@Name='ProxyDeploy']")) { pref.RemoveChild(node); } XmlHelper h = new XmlHelper(pref); XmlElement p = h.AddElement(".", "Property"); p.SetAttribute("Name", "ProxyDeploy"); XmlHelper ph = new XmlHelper(p); foreach (DataGridViewRow row in dgSites.Rows) { if (row.IsNewRow) { continue; } XmlElement t = row.Tag as XmlElement; if (t == null) { continue; } ph.AddElement(".", t); } _project.UpdateProjectPreference(pref); }