I have an xml file that I am using linq-to-XML to read. Linq-to-XML is preserving the line breaks and spaces for indenting.
So instead of having a guid like this:
"FB5417E2-DB15-481d-80D6-D0C4CB26EB1F"
I am getting stuff like this:
"\n FB5417E2-DB15-481d-80D6-D0C4CB26EB1F"
I have made this method to try and help compensate for this:
public static string ValueTrimmed(this XElement element)
{
if (element != null)
// Remove the newlines and spaces
return element.Value.Replace("\n ", "");
return "";
}
The problem is that this only works for "\n" + 6 spaces.
Is there a way to remove "\n" + Any number of spaces?
Note: I have some scenarios where the "\n" + x spaces is on the inside of the value.
For example:
TextTextTextTextTextTextText\n TextTextTextTextTextTextText