I'll just ignore the fact that the order of your XML file does not follow the order of your txt file.
T write a parser for your file, you have to split your String by new line symbols (Environment.NewLine or "\n") and by "/" and then put the letters on a stack and write them to your with the required encapsulation one at a time.
Put a while loop around the resulting array and set it to the length of your array you have created with the new line splits. Create another loop for each line to split the symbols and put them on a stack.
While putting a symbol on the stack, write it to the file with "<" + symbol + ">". After you have put every symbol of the stack, you just need to pop them and write the symbol to the file ""
Split: C# Split A String By Another String
Maybe I'll write some code when I have time for it, but this should give you a general idea.