You can easily do that using Adobe Illustrator SDK.
1- You just have to make a recursive treewalk of the document model.
2- Then you could implement a visitor to serialize this the way you want.
Illustrator SDK provides all the api and the tool to make this job done.
Thomas.