getNamedItem: name
// 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); }