use the insertAfter method:
XmlDocument xDoc = new XmlDocument(); xDoc.Load(yourFile); XmlNode xElt = xDoc.SelectSingleNode("//name[@ref=\"a2\"]"); XmlElement xNewChild = xDoc.CreateElement("name"); xNewChild.SetAttribute("ref", "b2"); xNewChild.SetAttribute("type", "aaa"); xDoc.DocumentElement.InsertAfter(xNewChild, xElt);
Pierroz
source share