Thursday, 26 September 2013

Searching NodeList by an Array

Searching NodeList by an Array

I have a document that I'm searching through for specific instances,
however those instances are specified by the user and there are more than
one. Other than a for loop inside a for loop searching a Nodelist against
an array, is there a way I'm missing that wouldn't bog down the system? Or
an easier way?
So far, my code looks like this in abstract:
public void sortDoc(Document doc){
NodeList list = doc.getFirstChild().getChildNodes();
ArrayList<String> typeList = otherSorter.getTypes();
for(int i=0; i<list.getLength(); i++){
for(int j=0; j<typeList.size(); j++){
if(list.item(i).getNodeName()==typeList.get(j)){
doTheThing();
}
}
}
}
Thanks for any help you can give.

No comments:

Post a Comment