Java Utililty Methods XML Child Get

List of utility methods to do XML Child Get

Description

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

Method

ListgetChildElements(Element element)
get Child Elements
NodeList childNodes = element.getChildNodes();
List<Element> elements = new ArrayList<Element>();
for (int i = 0; i < childNodes.getLength(); i++) {
    Node n = childNodes.item(i);
    if (n instanceof Element) {
        elements.add((Element) n);
return elements;
VectorgetChildElements(Element parent)
The method return list of child elements.
if (parent == null)
    throw new IllegalArgumentException("Element can not be NULL");
Vector vect = new Vector();
Element elem = getFirstChild(parent);
while (elem != null) {
    vect.add(elem);
    elem = getNextSibling(elem);
return vect;
ListgetChildElements(Element parent)
get Child Elements
List<Element> elems = new ArrayList<Element>();
NodeList nodes = parent.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
    Node node = nodes.item(i);
    if (node.getNodeType() == Node.ELEMENT_NODE) {
        elems.add((Element) node);
return elems;
ListgetChildElements(Element parent)
Returns all child elements of the given element.
Vector v = new Vector();
NodeList nl = parent.getChildNodes();
int length = nl.getLength();
for (int i = 0; i < length; i++) {
    Node node = nl.item(i);
    if (node.getNodeType() == Node.ELEMENT_NODE) {
        v.add((Element) node);
return v;
ListgetChildElements(Element parent)
Gets all child Element s of the given parent Element .
return getChildElements(parent, null);
ListgetChildElements(Element parent)
get Child Elements
if (null == parent)
    return null;
NodeList nodes = parent.getChildNodes();
List<Element> elements = new ArrayList<Element>();
for (int i = 0; i < nodes.getLength(); i++) {
    Node node = nodes.item(i);
    if (node.getNodeType() == Node.ELEMENT_NODE)
        elements.add((Element) node);
...
Element[]getChildElements(Element parent)
Gets all the child elements.
ArrayList a = new ArrayList();
NodeList children = parent.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
    Node item = children.item(i);
    if (!(item instanceof Element))
        continue;
    a.add(item);
return (Element[]) a.toArray(new Element[a.size()]);
ListgetChildElements(Element parent)
Get only the XML element children of an XML element.
NodeList childNodes = parent.getChildNodes();
List<Element> childElements = new ArrayList<>();
for (int index = 0; index < childNodes.getLength(); index++) {
    if (childNodes.item(index).getNodeType() == Node.ELEMENT_NODE) {
        childElements.add((Element) childNodes.item(index));
return childElements;
...
Element[]getChildElements(Element parent)
Gets all the child elements.
ArrayList a = new ArrayList();
NodeList children = parent.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
    Node item = children.item(i);
    if (!(item instanceof Element))
        continue;
    a.add(item);
return (Element[]) a.toArray(new Element[a.size()]);
ListgetChildElements(Element parent)
get Child Elements
ArrayList<Element> retval = new ArrayList<Element>();
Node n = parent.getFirstChild();
while (n != null) {
    if (n instanceof Element) {
        retval.add((Element) n);
    n = n.getNextSibling();
return retval;