write text structure as xml