It would help if you could provide a sample of the input "text table" and a sample of the output "xml table". Otherwise it is impossible to usefully answer your question.

Also it is appreciated to show some code you may have tried (but failed) to solve your problem.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James