List of utility methods to do XML Child Get
Element | getChild(Node node, String name, String attrName, String attrValue) Gets a child element of a node by name and attribute value. NodeList children = node.getChildNodes(); int numChildren = children.getLength(); for (int i = 0; i < numChildren; i++) { Node child = children.item(i); if (child.getNodeType() != Node.ELEMENT_NODE) continue; if (child.getNodeName().equals(name)) { Element el = (Element) child; ... |
Node | getChild(Node parent, String name) Get the first element child. if (parent == null) return null; Node first = parent.getFirstChild(); if (first == null) return null; for (Node node = first; node != null; node = node.getNextSibling()) { if (node.getNodeType() != Node.ELEMENT_NODE) continue; ... |
Node | getChild(Node parent, String name) get Child if (parent == null) { return null; Node first = parent.getFirstChild(); if (first == null) { return null; for (Node node = first; node != null; node = node.getNextSibling()) { ... |
List | getChildElements(Element e) get Child Elements List<Element> r = new ArrayList<Element>(); NodeList l = e.getChildNodes(); for (int i = 0; i < l.getLength(); i++) { Node n = l.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) r.add((Element) n); return r; ... |
List | getChildElements(Element e) Create a new list containing only the child nodes of e of type Element . List<Element> ret = new ArrayList<Element>(); NodeList children = e.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { ret.add((Element) child); return ret; |
List | getChildElements(Element e, String tag) get Child Elements NodeList children = e.getElementsByTagName(tag); if (children == null || children.getLength() == 0) return null; List<Element> result = new ArrayList<Element>(); for (int index = 0; index < children.getLength(); index++) { Node n = children.item(index); if (n.getNodeType() == Node.ELEMENT_NODE) { result.add((Element) n); ... |
Vector | getChildElements(Element el) Gets a list of the given element's child DOM elements. return getChildElements(null, el);
|
List | getChildElements(Element ele) Retrieve all child elements of the given DOM element Assert.notNull(ele, "Element must not be null"); NodeList nl = ele.getChildNodes(); List<Element> childEles = new ArrayList<Element>(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element) { childEles.add((Element) node); return childEles; |
List | getChildElements(Element ele) get Child Elements NodeList nl = ele.getChildNodes(); List<Element> childEles = new LinkedList<Element>(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element) { childEles.add((Element) node); return childEles; |
List | getChildElements(Element ele) Get all child elements List<Element> list = new ArrayList<>(); NodeList childNodes = ele.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { if (childNodes.item(i).getNodeType() == Node.ELEMENT_NODE) { list.add((Element) childNodes.item(i)); return list; ... |