Java Utililty Methods XML Element Get by ID

List of utility methods to do XML Element Get by ID

Description

The list of methods to do XML Element Get by ID are organized into topic(s).

Method

ElementgetElemenById(Document document, String elementId)
get Elemen By Id
Element element = document.getDocumentElement();
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if ((child.getNodeType() == Node.ELEMENT_NODE)
            && elementId.equals(((Element) child).getAttribute(ID_ATTRIBUTE)))
        return (Element) child;
return null;
NodegetElementById(Document doc, String id, Map idMap)
get Element By Id
if (!idMap.containsKey(id)) {
    registerIDs(doc, doc.getDocumentElement(), idMap);
return idMap.get(id);
ElementgetElementById(Document document, String id)
get Element By Id
return getElementById(document.getDocumentElement(), id);
ElementgetElementById(Document dom, String id)
get Element By Id
return getElementById(dom, id, "*"); 
ElementgetElementById(Document dom, String id, String localElementName)
get Element By Id
NodeList children = dom.getElementsByTagNameNS("*", localElementName); 
for (int i = 0; i < children.getLength(); i++) {
    Element element = (Element) children.item(i);
    if (element.getAttribute("id").equals(id)) {
        return element;
return null;
...