/** Return the child node with specified value for the "ID" attribute. */ private Node findChildWithID(Node root, String name, String id) { NamedNodeMap attributes = root.getAttributes(); if (attributes != null) { Node idNode = attributes.getNamedItem("ID"); if (idNode != null && id.equals(idNode.getNodeValue()) && name.equals(root.getNodeName())) { return root; } } NodeList children = root.getChildNodes(); for (int i=0; i<children.getLength(); i++) { Node result = findChildWithID(children.item(i), name, id); if (result != null) { return result; } } return null; }
/** Return the child node with specified value for the "ID" attribute. */ private Node findChildWithID(Node root, String name, String id) { NamedNodeMap attributes = root.getAttributes(); if (attributes != null) { Node idNode = attributes.getNamedItem("ID"); if (idNode != null && id.equals(idNode.getNodeValue()) && name.equals(root.getNodeName())) { return root; } } NodeList children = root.getChildNodes(); for (int i=0; i<children.getLength(); i++) { Node result = findChildWithID(children.item(i), name, id); if (result != null) { return result; } } return null; }
Node ref1 = findChildWithID(realRoot1, refName, n1.getNodeValue()); Node ref2 = findChildWithID(realRoot2, refName, n2.getNodeValue());
Node ref1 = findChildWithID(realRoot1, refName, n1.getNodeValue()); Node ref2 = findChildWithID(realRoot2, refName, n2.getNodeValue());