DomDocument.setAttribute

DomAttribute * setAttribute(DomElement * e, scope const(char)[] name, scope const(char)[] value) @nogc nothrow pure @safe

Set (or add) an attribute. The name is lowercased. It returns null if out of memory.