List of utility methods to do XML Has Child
boolean | hasNamedChild(Element e, String name) has Named Child Element c = getFirstChild(e); while (c != null && !name.equals(c.getLocalName()) && !name.equals(c.getNodeName())) c = getNextSibling(c); return c != null; |
boolean | hasNonWhitespaceChildren(Element element) check, if the passed element node has non-whitespace children. if (element.hasChildNodes()) { NodeList children = element.getChildNodes(); int len = children.getLength(); Node n = null; for (int i = 0; i < len; i++) { n = children.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { return true; ... |
boolean | hasOnlyTextChildNodes(final Node node) Checks if the given node has only text children. boolean result = true; final NodeList children = node.getChildNodes(); for (int i = 0; result && i < children.getLength(); i++) { final Node child = children.item(i); if (child.getNodeType() != Node.TEXT_NODE) { result = false; return result; |
boolean | hasOnlyTextChildren( Node node) has Only Text Children Node childNode = node.getFirstChild(); while (childNode != null) { if (!(childNode instanceof Text)) { return false; childNode = childNode.getNextSibling(); return true; ... |
boolean | hasTextChildNodesOnly(Node node) True if the node has text child elements only NodeList nodeList = node.getChildNodes(); if (nodeList.getLength() == 0) return false; for (int i = 0; i < nodeList.getLength(); i++) { Node acksToChildNode = nodeList.item(i); if (acksToChildNode.getNodeType() != Node.TEXT_NODE) return false; return true; |