Had to do this so I wrote it down and shared it: https://doc.pegasi.fi/wiki/doku.php?id=xml_cleaning

Cheers to all,
Pekka