Without working it out, I pass in a string to the function, and it traverses the XML document looking for matches. If it finds one, it changes the entered text into the found text.
If it doesn't find any, then it highlights the entered text as red.
If it finds more than one, it populates a dropdown list with each match, awaiting for the user to select an alternative.
Short, sweet, but pretty user-friendly even if I say so myself... lol.
The problem is, is that you could have for example "Bob Smith" in a different distribution list, in which case the following could happen...
User enters Bob.
System finds 5 instances of Bob [Bob Smith, Bob Jones, Bob Ball, Bob Ball, Bob Jones]
User selects Bob Smith
System changes Bob to Bob Smith
*User checks again
System Finds Bob Smith in two distribution lists
System shows Bob Smith twice
User Selects Bob Smith (again!)
Goto *...!!!
Hence why I wanted to return distinct names.
The solution I'm working on, is when the dropdown list is populated, to then filter out any duplicates, and if the length of the dropdown list is greater than 1, then show the alternatives, otherwise it must be a single-uniquely found name, and thus is correct...!