Your code is not making any sense. This line:
sb.AppendLine(string.IsNullOrEmpty(Text) ? node.Text : tag);
says if
Text
(whatever that is, it's not defined in the code snippet you posted) is null or String.Empty, append the
node.Text
content to the string builder. If
Text
is not null or empty, append the
node.Tag
contents.
What's
Text
, because that's what is driving what gets appended and is probably not what you expect.
Learn to the use the debugger and step through code and inspect variable contents. Without that skill, you're just guessing at what's wrong with your code.