List of utility methods to do XML Element Get by ID
Element | getElemenById(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; |
Node | getElementById(Document doc, String id, Map get Element By Id if (!idMap.containsKey(id)) { registerIDs(doc, doc.getDocumentElement(), idMap); return idMap.get(id); |
Element | getElementById(Document document, String id) get Element By Id return getElementById(document.getDocumentElement(), id);
|
Element | getElementById(Document dom, String id) get Element By Id return getElementById(dom, id, "*"); |
Element | getElementById(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; ... |