# Strip LF characters from XML data in <name> -à </name>
# and write to another file
inFile = open('C:\\YourDirectory\\Test.xml', 'r')
lineList = inFile.readlines()
inFile.close()
outFile = open('C:\\YourDirectory\\Test2.xml', 'w')
lastIndexS, lastIndexE = 0, 0
for item in lineList:
if '<name>' in item:
indexStart = lineList.index(item, lastIndexS+1)
lastIndexS = indexStart
if '</name>' in item:
indexEnd = lineList.index(item, lastIndexE+1)
lastIndexE = indexEnd
for i in range(indexStart, indexEnd):
if lineList[i] == '<name>\n':
lineList[i] = lineList[i].strip('\n')
else: lineList[i] = lineList[i].strip('\n')+" "
outFile.writelines(lineList)
outFile.close()