tags:

views:

79

answers:

3

I want to convert a tab delimited text file to a XML file. I was able to do it with a single character delimiter. But how do i extend it to tabs? I am coding in C# and using Visual Studio 2010.

+1  A: 

A tab is a single character, written as '\t'. Try adapting your existing solution to use that. If that doesn't work, post more details about your approach and the problems you encountered.

Blair Conrad
+1  A: 

Basically you want to split your lines using the tab char? In that case, use the method you already have and use \t for splitting.

riffnl
See answer by Blair Conrad :-) -- beat me to it
riffnl
+1  A: 

Are the tabs an \t symbol? Then the task is, basically, the same. If by tabs you mean multiple spaces, you might want to delete the extra spaces. A simple way is to use a regex:

  string input = "This is   text with   far  too   much   " + 
                 "whitespace.";
  string pattern = "\\s+";
  string replacement = " ";
  Regex rgx = new Regex(pattern);
  string result = rgx.Replace(input, replacement);
mcm69