Java XML Child Node Get getChildElements(Node start)

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

Description

returns a java.util.List of Elements which are children of the start Element.

License

BSD License

Declaration

public static List getChildElements(Node start) 

Method Source Code


//package com.java2s;
/*// w  w  w  .  j a va2s .c om
 * Copyright (c) 2012. betterFORM Project - http://www.betterform.de
 * Licensed under the terms of BSD License
 */

import org.w3c.dom.*;

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

public class Main {
    /**
     * returns a java.util.List of Elements which are children of the start Element.
     */
    public static List getChildElements(Node start) {
        List l = new ArrayList();
        NodeList nl = start.getChildNodes();
        int len = nl.getLength();
        Node n = null;

        for (int i = 0; i < len; i++) {
            n = nl.item(i);

            if (n.getNodeType() == Node.ELEMENT_NODE) {
                l.add(n);
            }
        }

        return l;
    }
}

Related

  1. getChildElements(Node node)
  2. getChildElements(Node node)
  3. getChildElements(Node node)
  4. getChildElements(Node parent)
  5. getChildElements(Node parent)
  6. getChildElements(NodeList list)
  7. getChildNode(Element item, String name)
  8. getChildNode(Node n, String name)
  9. getChildNode(Node n, String name)