iTunes: How to re-create your iTunes library and playlists - http://support.apple.com/kb/ht1451
Note that an xml version of your library is not 100% identical to the original .itl version, but you'll have to weigh up what makes the difference.
I don't know why your library isn't saving. You may have a directory error on your computer. Maybe there's some other conflict. It could even be an iTunes issue except if it were then I would expect more people to report it more than maybe once every couple of months. I have been using iTunes for the past 13 years and never had this problem.
How much free space do you have on your hard drive?
Thanks for the reply. The space on my HDD is another issue i'm working on, I do get the message sometimes that the HDD is full but i dont see how as the only files saved on the machine are from iphoto 100gb and itunes 40-60gb, the HDD is 250gb.
If I need more space on the HDD I can make this by moving files off and onto an external drive if you believe it will help prevent these problems, in the mean time I shall follow the link you provided and try that out.
If it happens again should I take a chance with in-store "genius" bar to rule out an directory issues?
You can verify your directory by running Disk Utility > first aid verify.
Have a look at how space is being used:
OmniDiskSweeper (free) - http://www.omnigroup.com/applications/omnidisksweeper/download/
OS X Lion: About Time Machine's "local snapshots" on portable Macs - http://support.apple.com/kb/HT4878 - “You may notice a difference in available space statistics between Disk Utility, Finder, and Get Info inspectors. This is expected and can be safely ignored. The Finder displays the available space on the disk without accounting for the local snapshots, because local snapshots will surrender their disk space if needed."
Hidden local backups with Mac OS X Lion filling up your MacBook hard disk! - http://blog.valerio.de/post/19238158977/hidden-local-backups-with-mac-os-x-lion- filling-up-your - Time Machine using local drive to store backups when external drive is not available.