List of utility methods to do XML First Child Element
Element | getFirstChildElement(Element elm, String name) get First Child Element if (elm == null) { return null; NodeList nl = elm.getChildNodes(); for (int c = 0; c < nl.getLength(); c++) { Node node = nl.item(c); if (node.getNodeType() == Node.ELEMENT_NODE && (name == null || node.getNodeName().equals(name))) { return (Element) node; ... |
Element | getFirstChildElement(Element elm, String name) get First Child Element if (elm == null) return null; NodeList nl = elm.getChildNodes(); for (int c = 0; c < nl.getLength(); c++) { Node node = nl.item(c); if (node.getNodeType() == Node.ELEMENT_NODE && (name == null || node.getNodeName().equals(name))) return (Element) node; return null; |
Element | getFirstChildElement(Element elm, String name) get First Child Element if (elm == null) return null; NodeList nl = elm.getChildNodes(); for (int c = 0; c < nl.getLength(); c++) { Node node = nl.item(c); if (node.getNodeType() == Node.ELEMENT_NODE && (name == null || node.getNodeName().equals(name))) return (Element) node; return null; |
Element | getFirstChildElement(Element parent) Get the indexed Element. Node node = parent.getFirstChild(); while (node != null && !(node instanceof Element)) { node = node.getNextSibling(); return (Element) node; |
Element | getFirstChildElement(Element parent) get First Child Element NodeList children = parent.getChildNodes(); if (children.getLength() == 0) return null; for (int k = 0; k < children.getLength(); k++) { Node kid = children.item(k); if (kid instanceof Element) { return (Element) kid; return null; |
Element | getFirstChildElement(Element parent) get First Child Element Node child = parent.getFirstChild(); while (child != null) { if (child instanceof Element) { return (Element) child; child = child.getNextSibling(); return null; ... |
Element | getFirstChildElement(Element parent, String childName) get First Child Element if (parent.getElementsByTagName(childName).getLength() > 0) { return (Element) parent.getElementsByTagName(childName).item(0); return null; |
Element | getFirstChildElement(Element parent, String nsUri, String localPart) Gets the fist child of the given name, or null. NodeList children = parent.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node item = children.item(i); if (!(item instanceof Element)) continue; if (nsUri.equals(item.getNamespaceURI()) && localPart.equals(item.getLocalName())) return (Element) item; return null; |
Element | getFirstChildElement(Element parent, String tagName) Gets the first child Element of the given parent Element that has the given tag name. NodeList children = null; if (tagName == null) { children = parent.getChildNodes(); } else { children = parent.getElementsByTagName(tagName); for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); ... |
Element | getFirstChildElement(Element parent, String tagName) Get the first child element of a given name a parent element. return (Element) parent.getElementsByTagName(tagName).item(0);
|