List of utility methods to do XML Node Child Check
boolean | hasChild(Node node, String namespace, String name) Search for availability of a certain child. return getFirstChild(node, namespace, name) != null;
|
boolean | hasChildElement(NodeList list) Checks if the given NodeList contains a child element. Node n; for (int i = 0; i < list.getLength(); i++) { n = list.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { return true; return false; ... |
boolean | hasTextContent(Node child) has Text Content return child.getNodeType() != Node.COMMENT_NODE
&& child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE;
|
boolean | isDescendantOrSelf(Node ctx, Node descendantOrSelf) Returns true if the descendantOrSelf is on the descendant-or-self axis of the context node. if (ctx == descendantOrSelf) { return true; Node parent = descendantOrSelf; while (true) { if (parent == null) { return false; if (parent == ctx) { return true; if (parent.getNodeType() == Node.ATTRIBUTE_NODE) { parent = ((Attr) parent).getOwnerElement(); } else { parent = parent.getParentNode(); |
boolean | isInstance(Node node, String namespace, String name) Test if a node matches a namespace/name criteria, handling a null as match any. if (node.getNodeType() != Node.ELEMENT_NODE) { return false; if (namespace != null && !namespace.equals(node.getNamespaceURI())) { return false; if (name != null && !name.equals(node.getLocalName()) && !name.equals(node.getNodeName())) { ... |