using System; using System.Text; using System.Xml; //GNU General Public License version 2 (GPLv2) //http://cbasetest.codeplex.com/license class MainClass{ public static void SetAttributeValue(XmlNode xmlne, string name, object value) { SetAttributeValue(xmlne, name, value, null); } public static void SetAttributeValue(XmlNode xmlne, string name, string value) { XmlAttribute node = xmlne.OwnerDocument.CreateAttribute(name); xmlne.Attributes.Append(node); node.Value = value; } public static void SetAttributeValue(XmlNode xmlne, string name, object value, string defaultStr) { string str = defaultStr; if (value != null) { str = value.ToString(); } if (str != null) { SetAttributeValue(xmlne, name, str); } } }