Thursday 4 August 2011

Convert NodeList To Node Array

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

public class Utils {
  
  public static Node[] convertToArray(NodeList list)
  {
      int length = list.getLength();
      Node[] copy = new Node[length];
      
      for (int n = 0; n < length; ++n)
          copy[n= list.item(n);
      
      return copy;
  }
}

   
    
    
    
  

No comments:

Post a Comment