Java XML Child Get getChildElements(Element element)

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

Description

get Child Elements

License

Open Source License

Declaration

public static List<Element> getChildElements(Element element) 

Method Source Code


//package com.java2s;
/*/*from   w  ww  .j  a v a  2 s.c o m*/
 * This file is part of Dorado 7.x (http://dorado7.bsdn.org).
 * 
 * Copyright (c) 2002-2012 BSTEK Corp. All rights reserved.
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * and BSDN commercial (http://www.bsdn.org/licenses) licenses.
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at http://www.bstek.com/contact.
 */

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 element) {
        List<Element> list = new ArrayList<Element>();
        NodeList nodeList = element.getChildNodes();
        int size = nodeList.getLength();
        for (int i = 0; i < size; i++) {
            Node childNode = nodeList.item(i);
            if (childNode instanceof Element) {
                list.add((Element) childNode);
            }
        }
        return list;
    }
}

Related

  1. getChildElements(Element ele)
  2. getChildElements(Element ele, String childEleName)
  3. getChildElements(Element elem, String name)
  4. getChildElements(Element element)
  5. getChildElements(Element element)
  6. getChildElements(Element element)
  7. getChildElements(Element element)
  8. getChildElements(Element element)
  9. getChildElements(Element element)