If you mean using C #, then probably the easiest way is to load xml into an XmlDocument object, and then add a node representing an additional element.
eg. sort of:
string filePath = "original.xml"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filePath); XmlElement root = xmlDoc.DocumentElement; XmlNode nodeToAdd = doc.CreateElement(XmlNodeType.Element, "user", null); XmlNode idNode = doc.CreateElement(XmlNodeType.Element, "id", null); idNode.InnerText = "1"; XmlNode nameNode = doc.CreateElement(XmlNodeType.Element, "name", null); nameNode.InnerText = "a"; nodeToAdd.AppendChild(idNode); nodeToAdd.AppendChild(nameNode); root.AppendChild(nodeToAdd); xmlDoc.Save(filePath); // Overwrite or replace with new file name
But you did not say where the xml fragments are in files / lines?
source share