Question: how to convert text file to xml in c#?
Answer: 2 Answers. Assuming you need to add xml element for every line in txt, you can write similar to following (XLINQ). The following will open a file, read the contents, create a new XML document, and then save the results to the same path as the original, only with an XML extension.