rendered paste body public virtual XmlAttribute Remove (XmlAttribute node)
{
if (IsReadOnly)
throw new ArgumentException ("This attribute collection is read-only.");
if (node == null)
throw new ArgumentException ("Specified node is null.");
if (node.OwnerDocument != ownerDocument)
throw new ArgumentException ("Specified node is in a different document.");
if (node.OwnerElement != this.ownerElement)
throw new ArgumentException ("The specified attribute is not contained in the element.");
XmlAttribute retAttr = null;
for (int i = 0; i < Count; i++) {
XmlAttribute attr = (XmlAttribute) Nodes [i];
if (attr == node) {
retAttr = attr;
break;
}
}
if(retAttr != null) {
ownerDocument.onNodeRemoving (node, ownerElement);
base.RemoveNamedItem (retAttr.LocalName, retAttr.NamespaceURI);
RemoveIdenticalAttribute (retAttr);
ownerDocument.onNodeRemoved (node, ownerElement);
}
// If it is default, then directly create new attribute.
DTDAttributeDefinition def = retAttr.GetAttributeDefinition ();
if (def != null && def.DefaultValue != null) {
XmlAttribute attr = ownerDocument.CreateAttribute (
retAttr.Prefix, retAttr.LocalName, retAttr.NamespaceURI);
attr.Value = def.DefaultValue;
attr.SetDefault ();
this.SetNamedItem (attr);
}
retAttr.AttributeOwnerElement = null;
return retAttr;
}