# Marking up data in a text file as XML import sys print "Content-type: text/xml\n" print""" """ # Open data file: try: file = open( "names.txt", "r" ) except IOError: sys.exit( "Error opening file" ) print "" replaceList = [ ("&", "&"), ("<", "<"), (">", ">"), ('"', """), ("'", "'") ] for currentLine in file.readlines(): for oldValue, newValue in replaceList: currentLine = currentLine.replace( oldValue, newValue ) last, first = currentLine.split(", ") first = first.strip() #remove carriage return print """ %s %s """ % ( last, first ) file.close() print "" if __name__ == "__main__": None #print "Hello World"