I have an xElement data <a><item><item1/><item2/></item></a>
Need to replace item node with another node .
How can we achieve this?
I just need to replace item node with some other node say <b><b1/></b>
I want output as <a><b><b1/></b></a>
I have an xElement data <a><item><item1/><item2/></item></a>
Need to replace item node with another node .
How can we achieve this?
I just need to replace item node with some other node say <b><b1/></b>
I want output as <a><b><b1/></b></a>
Please find the below script, this is help you to replace the node
XElement xmlTree = new XElement("Students",
new XElement("Andrew", "Andrew Wilson"),
new XElement("Thomas", "Thomas Alwa"),
new XElement("Winston", "Winston GH"),
new XElement("Hary", "Hary Potter"),
new XElement("Jacky", "Jacky Elia")
);
XElement xel = xmlTree.Element("Winston");
xel.ReplaceWith(new XElement("Bill", "Bill Gate"));
Console.WriteLine(xmlTree);