Java XML NodeList convertToElementList(org.w3c.dom.NodeList _nodeList)

Here you can find the source of convertToElementList(org.w3c.dom.NodeList _nodeList)

Description

Convert a NodeList to a Java List of Element s.

License

Open Source License

Parameter

Parameter Description
_nodeList collection of nodes

Return

list of elements

Declaration

public static List<Element> convertToElementList(org.w3c.dom.NodeList _nodeList) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

import org.w3c.dom.Element;

public class Main {
    /**/*from w  w  w. j a v a 2 s . c om*/
     * Convert a {@link NodeList} to a Java {@link List} of {@link Element}s.
     * @param _nodeList collection of nodes
     * @return list of elements
     */
    public static List<Element> convertToElementList(org.w3c.dom.NodeList _nodeList) {
        List<org.w3c.dom.Element> elemList = new ArrayList<>();
        for (int i = 0; i < _nodeList.getLength(); i++) {
            Element elem = (org.w3c.dom.Element) _nodeList.item(i);
            elemList.add(elem);
        }
        return elemList;
    }
}

Related

  1. containsElementByValue(NodeList elements, String value)
  2. containsNature(NodeList nodes, String nature)
  3. convertNodelistToSet(NodeList xpathNodeSet)
  4. convertToArray(NodeList e)
  5. convertToArray(NodeList list)
  6. copyNodeList(NodeList nodeList)
  7. createNodeCollection(final NodeList nodeList)
  8. createRealNodeList(NodeList nodeList)
  9. equalNodes(NodeList sourceNodeList, NodeList targetNodeList)