List of utility methods to do XML Child Node Get
List | getChildElements(Node node) Returns a list of all child Elements, return getChildElements(node, null);
|
List | getChildElements(Node node) get Child Elements NodeList children = node.getChildNodes(); int childCount = children.getLength(); List<Node> nodes = new ArrayList<Node>(childCount); for (int i = 0; i < childCount; i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { nodes.add(child); return nodes; |
Stream | getChildElements(Node node) get Child Elements if (node == null) { return Stream.empty(); return toStream(node.getChildNodes()).filter(x -> x.getNodeType() == Node.ELEMENT_NODE) .map(x -> (Element) x); |
Collection | getChildElements(Node node) get Child Elements List<Element> elements = new ArrayList<Element>(); NodeList nodes = node.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node childNode = nodes.item(i); if (childNode instanceof Element) { elements.add((Element) childNode); return elements; |
List | getChildElements(Node parent) returns List of all direct child elements ArrayList retVec = new ArrayList(); NodeList children = parent.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { retVec.add(children.item(i)); return retVec; ... |
List | getChildElements(Node parent) get Child Elements List<Element> elements = new ArrayList<Element>(); for (Node n = parent.getFirstChild(); n != null; n = n.getNextSibling()) { if (n.getNodeType() == Node.ELEMENT_NODE) { elements.add((Element) n); return elements; |
List | getChildElements(Node start) returns a java.util.List of Elements which are children of the start Element. List l = new ArrayList(); NodeList nl = start.getChildNodes(); int len = nl.getLength(); Node n = null; for (int i = 0; i < len; i++) { n = nl.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { l.add(n); ... |
List | getChildElements(NodeList list) get Child Elements List<Element> result = new ArrayList<Element>(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node instanceof Element) { Element el = (Element) node; result.add(el); return result; |
Element | getChildNode(Element item, String name) get Child Node NodeList children = item.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node thisItem = (Node) children.item(i); if (thisItem != null && thisItem.getNodeName().equals(name) && thisItem.getParentNode() == item) { return (Element) thisItem; return null; ... |
Node | getChildNode(Node n, String name) get Child Node if (n == null) { throw new IllegalArgumentException("null node"); if (name == null) { throw new IllegalArgumentException("null name"); NodeList l = n.getChildNodes(); for (int i = 0; i < l.getLength(); i++) { ... |