Mega Code Archive

 
Categories / C# / XML LINQ
 

Adds the specified content immediately after this node

using System; using System.IO; using System.Xml; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         XElement xmlTree = new XElement("Root",             new XElement("A1", 1),             new XElement("A2", 2),             new XElement("A3", 3)         );         XElement child1 = xmlTree.Element("A1");         child1.AddAfterSelf(new XElement("NewA", 10));         Console.WriteLine(xmlTree);    } }