Java XML Child Node Get getChildElements(Node node)

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

Description

get Child Elements

License

Open Source License

Declaration

public static Collection<Element> getChildElements(Node node) 

Method Source Code

//package com.java2s;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class Main {
    public static Collection<Element> getChildElements(Node node) {
        List<Element> elements = new ArrayList<Element>();
        NodeList nodes = node.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node childNode = nodes.item(i);
            if (childNode instanceof Element) {
                elements.add((Element) childNode);
            }// w  w  w  .  j  a v  a 2 s . c om
        }
        return elements;
    }
}

Related

  1. getChildElements(Node node)
  2. getChildElements(Node node)
  3. getChildElements(Node node)
  4. getChildElements(Node node)
  5. getChildElements(Node node)
  6. getChildElements(Node parent)
  7. getChildElements(Node parent)
  8. getChildElements(Node start)
  9. getChildElements(NodeList list)