List of utility methods to do XML Has Child
boolean | hasChildElement(Element elem, String namespace, String localName) Checks if a DOM Element has a child element with the given qualified name. return elem.getElementsByTagNameNS(namespace, localName).getLength() > 0;
|
boolean | hasChildElement(Element element, String name) Returns true if the specified element has a child with the specified name or false otherwise.
NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { Element childElement = (Element) node; if (childElement.getNodeName().equals(name)) { return true; return false; |
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 | hasChildElement(TreeWalker walker) has Child Element Node current = walker.getCurrentNode(); Node child = walker.firstChild(); if (child != null) { walker.setCurrentNode(current); return true; return false; |
boolean | hasChildElementNodes(@Nonnull final Node aStartNode) Check if the passed node has at least one direct child element or not. return getFirstChildElement(aStartNode) != null;
|
boolean | hasChildElements(Element element) True if element has children elements NodeList childs = element.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { Node node = childs.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { return true; return false; ... |
boolean | hasChildElements(Element element) Determine whether an element has any child elements. Node child = element.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) return true; child = child.getNextSibling(); return false; |
boolean | hasChildElements(Element element) Indicates whether element has any child element. NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { return true; return false; ... |
boolean | hasChildElements(Node node) True if the node has child elements NodeList nlist = node.getChildNodes(); int len = nlist.getLength(); for (int i = 0; i < len; i++) { Node child = nlist.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) return true; return false; ... |
boolean | hasChildElements(Node node) True if the node has child elements. NodeList nlist = node.getChildNodes(); for (int i = 0; i < nlist.getLength(); i++) { Node child = nlist.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) return true; return false; |