import sys def search_xml(term_line, xml_path): xml = open(xml_path, 'r') for xml_line in xml: if term_line in xml_line: print("Found: " + term_line + " In:" + xml_line) def main(): xml_path = input("Enter file path for the XML: ") terms_path = input("Enter file path for the search list: ") print("") try: terms = open(terms_path, 'r') temp = open(xml_path, 'r') except OSError: print("Unable to find one or more of those files, try again. \n") main() for term_line in terms: term_line = term_line.strip('\n') search_xml(term_line, xml_path) rerun = input("Do you want to run the script again? Y/N ") print("") rerun = rerun.lower() if rerun == "y": main() else: sys.exit() if __name__ == '__main__': main()