Sunday, June 30, 2013

Remove XML Node

One way by using Linq:



string path = Path.Combine(Path.GetTempPath(), "Xml\\creditlimits.xml");

XElement root = XElement.Load(path);

root.Descendants("Limit")
.Where(x => x.Value == "925").Remove();

foreach (var item in root.Elements("Limit")) {
Console.WriteLine(item.Value);
}
root.Save(fileName);

wizend

No comments:

Post a Comment