Adds the specified content immediately before this node.
using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
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.AddBeforeSelf(new XElement("NewA", 10));
Console.WriteLine(xmlTree);
}
}
Related examples in the same category