List of utility methods to do XML Has Child
Hashtable | getChildHash(Element elem, String elementName, String attrName) get Child Hash if (elem == null) return null; NodeList nl = elem.getChildNodes(); if (nl == null) return null; Hashtable<String, Element> retlist = new Hashtable<String, Element>(100); for (int n = 0; n < nl.getLength(); n++) { Node child = nl.item(n); ... |
Element | getLastVisibleChildElement(Node parent, Hashtable hiddenNodes) Finds and returns the last visible child element node. Node child = parent.getLastChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE && !isHidden(child, hiddenNodes)) { return (Element) child; child = child.getPreviousSibling(); return null; ... |
boolean | hasActivityChildNode(Node node) Checks whether the node has a child node that represents a BPEL activity. boolean foundNonTextChild = false; for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { if (!(child instanceof Text)) { if (BPEL_ACTIVITIES.contains(child.getNodeName())) { foundNonTextChild = true; return foundNonTextChild; |
boolean | hasAnyChildElement(final Element e) has Any Child Element for (Node child = e.getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof Element) { return true; return false; |
boolean | hasChild(Element element, String child) Determine whether a single child is available of a particular type. NodeList nodes = element.getChildNodes(); Element ret = null; for (int i = 0; i < nodes.getLength(); i++) { Node childNode = nodes.item(i); if (childNode.getNodeName().equals(child) && childNode.getNodeType() == Node.ELEMENT_NODE) { if (ret != null) { throw new Exception("Child element '" + child + "' present multiple times"); } else { ... |
boolean | hasChild(Element node, String name) This method checks whether the given element node has a child element with the given name. List<Element> children = getDirectChildElementsByTag(node, DOM_WILDCARD); for (Element e : children) { if (e.getNodeName().equals(name)) { return true; return false; |
boolean | hasChild(Element parent, String nodeName) has Child NodeList childNodes = parent.getChildNodes(); int length = childNodes.getLength(); for (int i = 0; i < length; i++) if (childNodes.item(i).getNodeName().equals(nodeName)) return true; return false; |
boolean | hasChild(Element root, String childName) has Child return (root.getElementsByTagName(childName).getLength() > 0);
|
boolean | hasChild(Element start, String name) __UNDOCUMENTED__ NodeList nl = start.getChildNodes(); int len = nl.getLength(); Node n = null; for (int i = 0; i < len; i++) { n = nl.item(i); if (n.getNodeName().equals(name)) { return true; return false; |
boolean | hasChild(Node n) has Child NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { n = nl.item(i); if (n.getNodeType() == 1) return true; return false; |