Java XML Child Get getChildElements(Element parent)

Here you can find the source of getChildElements(Element parent)

Description

get Child Elements

License

LGPL

Declaration

public static List<Element> getChildElements(Element parent) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.ArrayList;

import java.util.List;

import org.w3c.dom.Element;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static List<Element> getChildElements(Element parent) {
        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);
            }//from   w w  w. j av a  2  s .com
        }
        return elems;
    }
}

Related

  1. getChildElements(Element element)
  2. getChildElements(Element element)
  3. getChildElements(Element element)
  4. getChildElements(Element element)
  5. getChildElements(Element parent)
  6. getChildElements(Element parent)
  7. getChildElements(Element parent)
  8. getChildElements(Element parent)
  9. getChildElements(Element parent)