.NET Framework ネタ

XmlDocument xd = new XmlDocument();
xd.AppendChild(xd.CreateXmlDeclaration("1.0", "UTF-8", null));
xd.AppendChild(xd.CreateElement("root"));
XmlElement xe = xd.CreateElement("element");
xe.SetAttribute("attribute", "value");
xe.InnerText = "text";
xd.DocumentElement.AppendChild(xe);
xd.Save("x.xml");
XmlDocument xd = new XmlDocument();
xd.Load("x.xml");
XmlNode xn = xd.DocumentElement.SelectSingleNode("/root/element[attribute::attribute='value']");
if (xn != null)
{
Console.WriteLine(xn.InnerText);
xn.InnerText = "てすと";
xd.Save("x.xml");
}
…成る程