Java XML Child Node Get getChildElements(Node node)

Here you can find the source of getChildElements(Node node)

Description

get Child Elements

License

Apache License

Declaration

public static Collection getChildElements(Node node) 

Method Source Code

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static Collection getChildElements(Node node) {
        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);
            }//from www .j av  a  2  s  .c  om
        }
        return elements;
    }
}

Related

  1. getChildElements(final Node node)
  2. getChildElements(final Node parentNode, final String... childNodeNames)
  3. getChildElements(Node element)
  4. getChildElements(Node node)
  5. getChildElements(Node node)
  6. getChildElements(Node node)
  7. getChildElements(Node node)