Easy Tutorial
❮ Dom Httprequest Dom Met Node Isequalnode ❯

XML DOM getAttributeNode() Method



Definition and Usage

The getAttributeNode() method retrieves an attribute node from the current element by name.

Syntax

Parameter Description
name Required. Specifies the attribute node to retrieve.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc and retrieves the "category" attribute from all <book> elements:

Example

xmlDoc = loadXMLDoc("books.xml");

x = xmlDoc.getElementsByTagName('book');

for (i = 0; i < x.length; i++) {
  attnode = x.item(i).getAttributeNode("category");
  document.write(attnode.name);
  document.write(" = ");
  document.write(attnode.value);
  document.write("<br>");
}

Output:

category = COOKING
category = CHILDREN
category = WEB
category = WEB

❮ Dom Httprequest Dom Met Node Isequalnode ❯