// Example: public static string AttributeToText(this XmlElement rootElement, string attributeName, string defaultValue) { XmlAttribute attribute = rootElement.GetOrCreateAttribute(attributeName); return(attribute.ReadString(defaultValue)); }