Click to return to the XML (Extensible Markup Language) home page    
IXMLDOMElement::removeAtt...     IXMLDOMElement::setAttrib...     IXMLDOMElement Interface    
Web Workshop  |  XML (Extensible Markup Language)

IXMLDOMElement::setAttribute Method


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.



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.