Found the answer, and it is very basic (I lost sight of the fact that the whole 'selectNodes' is taking a string):
Instead of:
contactNodes = thisXDocument.GetDOM("Contacts").selectNodes("ContactData/Contact[contains(last_name, searchString)]");
I needed to do the following:
contactNodes = thisXDocument.GetDOM("Contacts").selectNodes("ContactData/Contact[contains(last_name,'" + searchString + "')]");