public static void AddAttribute(this XmlElement xmlElement, string attributeName, string value) { XmlAttribute attr = xmlElement.OwnerDocument.CreateAttribute(attributeName); attr.Value = value; xmlElement.Attributes.Append(attr); }