Java XML NodeList copyNodeList(NodeList nodeList)

Here you can find the source of copyNodeList(NodeList nodeList)

Description

Copy a given NodeList into a List

License

Open Source License

Parameter

Parameter Description
nodeList Node List.

Return

List with the elements of nodeList.

Declaration

public static List<Node> copyNodeList(NodeList nodeList) 

Method Source Code

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

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.*;

public class Main {
    /**/*  w w  w  .j a  v  a  2  s .  co  m*/
     * Copy a given NodeList into a List<Element>
     *
     * @param nodeList Node List.
     * @return List with the elements of nodeList.
     */
    public static List<Node> copyNodeList(NodeList nodeList) {
        ArrayList<Node> copy = new ArrayList<Node>();
        int length = nodeList.getLength();

        for (int i = 0; i < length; i++) {
            copy.add((Node) nodeList.item(i));
        }

        return copy;
    }
}

Related

  1. containsNature(NodeList nodes, String nature)
  2. convertNodelistToSet(NodeList xpathNodeSet)
  3. convertToArray(NodeList e)
  4. convertToArray(NodeList list)
  5. convertToElementList(org.w3c.dom.NodeList _nodeList)
  6. createNodeCollection(final NodeList nodeList)
  7. createRealNodeList(NodeList nodeList)
  8. equalNodes(NodeList sourceNodeList, NodeList targetNodeList)
  9. extractElementsFromNodeList(NodeList config, String tag, boolean required)