Link Search Menu Expand Document

XmlElement.SetAttributeNode Method

Explanation Specify the XmlAttrobject to configure the Attr node.
If there is an Attr node with the same attribute name as the specified XmlAttr object, replace the Attr node.
Not supported in Mobile, AI
Call format var attr2 = elm.SetAttributeNode( attr )
Return value Replaced XmlAttr object.
Returns null if there was no replacement.
Arguments XmlAttr attr XmlAttr object to be set
You cannot specify an Attr node that is already set on another Element node.
Exception DOM-4 WRONG_DOCUMENT_ERR
DOM-7 NO_MODIFICATION_ALLOWED_ERR
DOM-10 INUSE_ATTRIBUTE_ERR
Example of use
    var domimpl = new XmlDOMImplementation;
    var res = session.Get("/test/sample.xml");
    var xmldoc = domimpl.Load(res);
    var elm = xmldoc.DocumentElement;
    var attr = elm.GetAttributeNode("width");
    var attr2 = attr.CloneNode(true);
    elm.SetAttributeNode(attr2);
    
Related item XmlAttr class
GetAttributeNode, RemoveAttributeNode, SetAttribute, SetAttributeNS, SetAttributeNodeNS method