Java Utililty Methods XML Child Node Get

List of utility methods to do XML Child Node Get

Description

The list of methods to do XML Child Node Get are organized into topic(s).

Method

Element[]getChildElements(final Node node)
Enumerates all of the child Element s of the specified Node .
return getChildElementsInternal(node, false, null, null);
ListgetChildElements(final Node parentNode, final String... childNodeNames)
Get all child elements with the specified name(s) from the given parent node.
final List<Element> children = new LinkedList<Element>();
final NodeList candidates = parentNode.getChildNodes();
final int childCount = candidates.getLength();
final List<String> targetNodeNames = Arrays.asList(childNodeNames);
for (int childIndex = 0; childIndex < childCount; childIndex++) {
    final Node singleChild = candidates.item(childIndex);
    if (singleChild instanceof Element && (targetNodeNames.isEmpty()
            || targetNodeNames.contains(((Element) singleChild).getTagName()))) {
...
ListgetChildElements(Node element)
get Child Elements
List<Element> childElems = new ArrayList<Element>();
for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) {
    if (node instanceof Element) {
        childElems.add((Element) node);
return childElems;
CollectiongetChildElements(Node node)
get Child Elements
List elements = new ArrayList();
NodeList nodes = node.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
    Node childNode = nodes.item(i);
    if (childNode instanceof Element) {
        elements.add(childNode);
return elements;
ListgetChildElements(Node node)
Return a list of child element types of the provided node.
NodeList list = node.getChildNodes();
ArrayList<Element> elements = new ArrayList<Element>();
for (int i = 0; i < list.getLength(); i++) {
    Node temp = list.item(i);
    if (temp.getNodeType() == Node.ELEMENT_NODE)
        elements.add((Element) temp);
return elements;
...
ListgetChildElements(Node node)
Gets all child elements.
ArrayList<Element> ret = new ArrayList<Element>(5);
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
    if (child.getNodeType() == Node.ELEMENT_NODE) {
        ret.add((Element) child);
return ret;
ListgetChildElements(Node node)
Return a list of the elements that are direct children of the given node.
NodeList childNodes = node.getChildNodes();
List result = new ArrayList(childNodes.getLength());
for (int i = 0; i < childNodes.getLength(); i++) {
    Node oneChild = childNodes.item(i);
    if (oneChild instanceof Element)
        result.add(oneChild);
return result;
...
ListgetChildElements(Node node)
get Child Elements
return getNodesOfType(node.getChildNodes(), Node.ELEMENT_NODE);
ListgetChildElements(Node node)
get Child Elements
ArrayList<Element> list = new ArrayList<Element>();
NodeList nl = node.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
    Node n = nl.item(i);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        list.add((Element) nl.item(i));
return list;
ArrayListgetChildElements(Node node)
get Child Elements
ArrayList<Element> l = new ArrayList<Element>();
for (Node childNode = node.getFirstChild(); childNode != null;) {
    if (childNode.getNodeType() == Node.ELEMENT_NODE) {
        Element elem = (Element) childNode;
        l.add(elem);
    Node nextChild = childNode.getNextSibling();
    childNode = nextChild;
...