Link Search Menu Expand Document

XmlNamedNodeMap.SetNamedItem Method

Explanation Specify the XmlNode object to set the node.
If the node map already contains a node with the same name as the specified node, that node will be replaced.
Call format var node = map.SetNamedItem( newNode )
Return value Replaced XmlNode object
Returns null if the replacement did not occur .
Arguments XmlNode newNode Node to be set
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 map = xmldoc.DocumentElement.Attributes;
    var attr = xmldoc.CreateAttribute("width");
    attr.Value = "10";
    map.SetNamedItem(attr);
    
Related item XmlNode class
GetNamedItem, RemoveNamedItem, SetNamedItemNS method
[ ] operator