Mega Code Archive
0533 Get attribute out of element and change its value
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
class Program
{
static void Main()
{
string xml = @"";
XElement config = XElement.Parse(xml);
XElement client = config.Element("client");
bool enabled = (bool)client.Attribute("enabled"); // Read attribute
Console.WriteLine(enabled); // True
client.Attribute("enabled").SetValue(!enabled); // Update attribute
}
}
The output:
False