have a function that sends a search term, xmllist & content to be searched (with indexes at end of each line to represent item in xmllist). the function then outputs and xmllist of the found nodes that have the search term in them however if the the text in the node has two or more words that are the same it will add that node however many times that word appears.
How do I prevent this. I have attached the code.
function searchStringInAttribute(list:XMLList, attributelist:String, term:String):XMLList {
var output:XMLList = new XMLList();
var i:Number = 0;
var pos:Number = 0;
var index:int = 0;
var count:int = 0;
while (i > -1) {
pos = attributelist.indexOf(term, i);
if (pos > -1) {
index = int( attributelist.substring(attributelist.indexOf("<", pos)+1, attributelist.indexOf(">", pos)) );
output[count] = list[index];
count++;
i = pos+term.length;
} else {
i = pos;
}
}
return output;
}