Java XML Child Node Get getChildElements(NodeList list)

Here you can find the source of getChildElements(NodeList list)

Description

get Child Elements

License

Open Source License

Declaration

public static List<Element> getChildElements(NodeList list) 

Method Source Code

//package com.java2s;
/**//from w  ww. j av a2  s .  c  om
 *  Copyright (c) 2015 Genuitec LLC.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  Contributors:
 *  Piotr Tomiak <piotr@genuitec.com> - initial API and implementation
 */

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

Related

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