Element ele = document.getElementByTagName("book").item(0); String isbn = ele.getAttribute("isbn");
Element ele = document.createElement("employee"); ele.setAttribute("id", "1"); ele.setAttribute("name", "John"); String id = ele.getAttribute("id"); String name = ele.getAttribute("name");In this code example, the setAttribute method is used to set the values of the "id" and "name" attributes for a newly created "employee" element. The getAttributeValue method is then used to retrieve the values of these attributes. Package Library: The getAttributeValue method is part of the Java DOM (Document Object Model) API, which is included in the javax.xml package.