Saving to XML added.

Note: pull this request and merge it last (after the previous pull request). Now adds the ability to save.