Easy Tutorial
❮ Met Comment Appenddata Met Element Removechild ❯

XML DOM setAttributeNode() Method



Definition and Usage

The setAttributeNode() method adds a new attribute node.

If an attribute with the specified name already exists in the element, it is replaced by the new attribute. If the new attribute replaces an existing one, the replaced attribute node is returned; otherwise, it returns NULL.

Syntax

Parameter Description
att_node Required. Specifies the attribute node to be set.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc and adds an "edition" attribute to all <book> elements:

Example

Output:

Edition: first

❮ Met Comment Appenddata Met Element Removechild ❯