Handle Python syntax errors in xml