Have you ever took a look at SVG file how it's written?
It's an xml file.
So one solution would be: read image by image as xml and save required data into a string.
When you are finished gathering data, you only write generated string into an xml file.
And a quick tutorial on svg "here":http://www.w3schools.com/svg/default.asp
Regards,
Jake