From http://www.w3schools.com (Copyright Refsnes Data)
Complete Element Object Reference
The setAttributeNode() method adds a new attribute node.
If an attribute with that name already exists in the element, it is replaced by the new one. If the new attribute replaces an existing attribute, the replaced attribute node is returned, otherwise it returns null.
| elementNode.setAttributeNode(att_node) |
| Parameter | Description |
|---|---|
| att_node | Required. Specifies the attribute node to set |
The following code fragment loads "books.xml" into xmlDoc using loadXMLDoc() and adds a "edition" attribute to all <book> elements:
Example
Output:
Try it yourself » |
Complete Element Object Reference
From http://www.w3schools.com (Copyright Refsnes Data)