Microsoft XML 2.5 SDK


 

IXMLDOMElement::setAttribute Method

[This is preliminary documentation and subject to change.]

Sets the value of the named attribute.

Visual Basic Syntax

oXMLDOMElement.setAttribute(name, value)

C/C++ Syntax

HRESULT setAttribute(

    BSTR name,

    VARIANT value);

Parameters

name

[in]
Name of the attribute. If an attribute with that name already exists, its value is changed. If an attribute with that name does not exist, it is created.

value

[in]
Value for the named attribute.

C/C++ Return Values

S_OK

Value returned if successful.

E_FAIL

Value returned if an error occurs.

Remarks

If an attribute with the supplied name already exists, this method changes its value to the supplied value parameter. The supplied string is not parsed, so any markup is treated as literal text (such as syntax to be recognized as an entity reference), and needs to be appropriately escaped by the implementation when it is written out.

To assign an attribute value that contains entity references, the user must create an IXMLDOMAttribute object plus any IXMLDOMText and IXMLDOMEntityReference objects, build the appropriate subtree, and call the setAttributeNode method.

C/C++ Example

See Example for getAttribute Method