def makeXML(self): from xml.dom.minidom import Document data = self.dataDict doc = Document() match = doc.createElement('match') match.setAttribute('name', data['match']) match.setAttribute('result', data['result']) match.setAttribute('t1Points', "|".join(data['resultStr']['p1'])) match.setAttribute('t2Points', "|".join(data['resultStr']['p2'])) doc.appendChild(match) team = doc.createElement('team') team.setAttribute('pos', '1') match.appendChild(team) for pl in data['team1']: player = doc.createElement('player') for k,v in pl.items(): player.setAttribute(k, str(v)) team.appendChild(player) team.appendChild(player) team = doc.createElement('team') team.setAttribute('pos', '2') match.appendChild(team) for pl in data['team2']: player = doc.createElement('player') for k,v in pl.items(): player.setAttribute(k, str(v)) team.appendChild(player) doc.normalize() return doc.toprettyxml(indent=" ")