After some exhaustive research it seems your problem is not unique. There have been changes to iTunes recently that may have worsened the problem, see this article:
http://www.macworld.com/article/299...library-dealing-with-duplicate-playlists.html
Using the link in this article I went to this site;
http://www.mcelhearn.com/how-to-rebuild-your-itunes-library/
I am unsure if this will be any help to you now but it does explain some things.
It's possible that your iTunes Library became corrupted so creating an .xml file may be too late.
In the end it would have been so much easier to restore if you had a backup. Obviously this is no comfort to you now but it is why we all constantly harp on the importance of both A Time Machine Backup and a bootable Clone of your HD.
This has been a learning experience for me as well and I have followed the advice from the iTunes Guy to create an .xml file myself just for experimentation even though I have several backups.
At least you do have a solution, albeit a slow one but I strongly suggest that you backup and if like me you find iCloud an unnecessary complication for Pictures and Music turn off iTunes match and iCloud services for both.
I do not suggest turning off all iCloud services many are extremely useful but as far as iTunes and Photos go I find they sometimes create more problems than solutions. (personal opinion only)