Microsoft XML SDK 2.6 - XML Reference

IXMLDOMElement::setAttributeNode Method

Adds or changes the supplied attribute node on this element.

Visual Basic Syntax

Set objXMLDOMAttribute = oXMLDOMElement.XMLDOMElement(DOMAttribute)

C/C++ Syntax

HRESULT setAttributeNode(
    IXMLDOMAttribute *DOMAttribute,
    IXMLDOMAttribute **attributeNode);

Parameters

DOMAttribute [in]
Attribute node that is to be associated with this element.
attributeNode [out]
Null unless the new attribute replaces an existing attribute with the same name, in which case this method returns the previous, replaced attribute node.

C/C++ Return Values

S_OK
Value returned if successful.
E_FAIL
Value returned if an error occurs.

Remarks

You cannot add an existing attribute to an element until you first remove it from its previous element. Also, you cannot add a namespace-qualified attribute when it uses the same prefix as another attribute with a different namespaceURI.

C/C++ Example

See the example given for the getAttributeNode method.

See Also

IXMLDOMElement Interface