rewrote xmlGallery to support writing