Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Node findByID(Document doc, String id, String tagName) { NodeList node = doc.getElementsByTagName(tagName); for (int i = 0; i < node.getLength(); i++) { NamedNodeMap attributtes = node.item(i).getAttributes(); for (int j = 0; j < attributtes.getLength(); j++) if (id.equalsIgnoreCase(attributtes.item(j).getNodeValue())) return node.item(i); } return null; } }