I have been in stuck with similar problem. Finally figured out the what was the root cause in my particular case. If you read the data from multiple XML files that lie in same folder you will parse also .DS_Store file. Before parsing add this condition
for file in files:
if file.endswith('.xml'):
run_your_code...
This trick helped me as well