Java XML NodeList convertNodelistToSet(NodeList xpathNodeSet)

Here you can find the source of convertNodelistToSet(NodeList xpathNodeSet)

Description

Method convertNodelistToSet

License

Apache License

Parameter

Parameter Description
xpathNodeSet a parameter

Return

the set with the nodelist

Declaration

public static Set<Node> convertNodelistToSet(NodeList xpathNodeSet) 

Method Source Code

//package com.java2s;
/* NOTICE: This file has been changed by Plutext Pty Ltd for use in docx4j.
 * The package name has been changed; there may also be other changes.
 * /*from  www  .j  a v  a2s . c om*/
 * This notice is included to meet the condition in clause 4(b) of the License. 
 */

import java.util.HashSet;

import java.util.Set;

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

public class Main {
    /**
     * Method convertNodelistToSet
     *
     * @param xpathNodeSet
     * @return the set with the nodelist
     */
    public static Set<Node> convertNodelistToSet(NodeList xpathNodeSet) {
        if (xpathNodeSet == null) {
            return new HashSet<Node>();
        }

        int length = xpathNodeSet.getLength();
        Set<Node> set = new HashSet<Node>(length);

        for (int i = 0; i < length; i++) {
            set.add(xpathNodeSet.item(i));
        }

        return set;
    }
}

Related

  1. canonizeNodeList(NodeList nodelist)
  2. combine(final NodeList... nls)
  3. combineNodeLists(NodeList successfulReportList, NodeList failedAssertList)
  4. containsElementByValue(NodeList elements, String value)
  5. containsNature(NodeList nodes, String nature)
  6. convertToArray(NodeList e)
  7. convertToArray(NodeList list)
  8. convertToElementList(org.w3c.dom.NodeList _nodeList)
  9. copyNodeList(NodeList nodeList)