Mega Code Archive

 
Categories / C# / XML LINQ
 

XAttribute SetValue sets the value of this attribute

using System; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         XElement root = new XElement("Root",             new XAttribute("Att1", "content1"),             new XAttribute("Att2", "content2"),             new XAttribute("Att3", "content3")         );         XAttribute att = root.Attribute("Att2");         att.SetValue("new content");         Console.WriteLine(root);    } }