reorganize xml structure and output.