Java XML Element Get getElements(Element node)

Here you can find the source of getElements(Element node)

Description

Search the children of the argument node for elements.

License

LGPL

Parameter

Parameter Description
node The parent node element.

Return

The list of elements.

Declaration

public static ArrayList<Element> getElements(Element node) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 *                        Web3d Consortium Copyright (c) 2007 - 2008
 *                               Java Source
 *
 * This source is licensed under the GNU LGPL v2.1
 * Please read http://www.gnu.org/copyleft/lgpl.html for more information
 *
 * This software comes with the standard NO WARRANTY disclaimer for any
 * purpose. Use it at your own risk. If there's a problem you get to fix it.
 *
 *****************************************************************************/

import java.util.ArrayList;

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

public class Main {
    /**/*ww  w .  ja  v  a2 s. c  o m*/
     * Search the children of the argument node for elements.
     *
     * @param node The parent node element.
     * @return The list of elements.
     */
    public static ArrayList<Element> getElements(Element node) {

        ArrayList<Element> list = new ArrayList<Element>();
        // note that we need to preserve the order of the child elements,
        // transformational elements of a Collada node must be processed
        // in order.
        NodeList nl = node.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node n = nl.item(i);
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                Element e = (Element) n;
                list.add(e);
            }
        }
        return (list);
    }
}

Related

  1. getElements(Element aElement)
  2. getElements(Element document, String elementName, String attrName, String attrValue)
  3. getElements(Element elem, String path)
  4. getElements(Element element)
  5. getElements(Element element, String tagName)
  6. getElements(Element root)
  7. getElements(Element root, String element)
  8. getElements(Element root, String tagName)
  9. getElements(Element topElm)