Name

getNamedItem: name

Synopsis

Returns a reference to the node with the given nodeName property specified by name.

Argument

name: DOMString

Name of the node to retrieve.

Java binding

public Node getNamedItem(String name);

Java example

// Check to see if an ID attribute exists
// in this map, and add it if necessary
// nnm was created by getting the attributes
// from an element
if (nnm.getNamedItem("id") =  = null) {
    // get the document
    Document doc = elem.getOwnerDocument( );
    // create a new attribute Node
    Attr attrID = doc.createAttribute("id");
     
    // set the attribute value
    attrID.appendChild(doc.createTextNode(makeUniqueID(elem)));
    // ... and add it to the NamedNodeMap
    nnm.setNamedItem(attrID);
}

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.