XML document construction