erminas.SmartAPI.Utils.XmlUtil.SetAttributeValue C# (CSharp) Method

SetAttributeValue() public static method

Sets an attribute to a value. If no fitting XmlAttribute exists, a new one is created/appended and its value set.
public static SetAttributeValue ( this xmlElement, string attributeName, string value ) : void
xmlElement this The node
attributeName string Name of the attribute
value string Value to set the attribute to
return void
        public static void SetAttributeValue(this XmlElement xmlElement, string attributeName, string value)
        {
            XmlAttribute attr = xmlElement.Attributes[attributeName];
            if (attr == null)
            {
                AddAttribute(xmlElement, attributeName, value);
            }
            else
            {
                attr.Value = value;
            }
        }