List of utility methods to do XML Child Get by Name
Element | getChildElement(Element parent, String element) Helper to get the first child element with given name. NodeList nodes = parent.getChildNodes(); if (nodes == null || nodes.getLength() == 0) return null; Element ret = null; for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && child.getLocalName().equals(element)) { ret = (Element) child; ... |
Element | getChildElement(Element parent, String name) get Child Element NodeList childNdList = parent.getChildNodes(); if (childNdList == null) { return null; for (int i = 0; i < childNdList.getLength(); i++) { org.w3c.dom.Node n = childNdList.item(i); if (n == null) { continue; ... |
Element | getChildElement(Element parent, String name) get Child Element return getChildElement(parent, name, false);
|
Element | getChildElement(Element parent, String name) Gets the child Element with the indicated name. Element elem; if ((elem = firstChildElement(parent)) == null) { return null; if (elem.getNodeName().equals(name)) { return elem; while ((elem = nextSiblingElement(elem)) != null) { ... |
Element | getChildElement(Element parent, String tagName) get Child Element return (Element) parent.getElementsByTagName(tagName).item(0);
|
Element | getChildElement(Element parent, String tagName) get Child Element List<Element> elements = getElements(parent, tagName);
return (elements.size() > 0) ? elements.get(0) : null;
|
Element | getChildElement(Element parent, String tagName) get Child Element List<Element> children = getChildElements(parent, tagName); if (children.isEmpty()) { return null; return (Element) children.get(0); |
Element | getChildElement(Element parent, String tagName) get Child Element return getChildElement(parent, tagName, false);
|
Element | getChildElement(Element parent, String tagName) Gets the immediately child element from the parent element. List<Element> children = getChildElements(parent, tagName); if (children.isEmpty()) { return null; } else { return children.get(0); |
Element | getChildElement(Element parentElement, String childElementName) get Child Element NodeList children = parentElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && childElementName.equals(getNodeName(child))) return (Element) child; return null; |