how to remove carriage returns, newlines, spaces from a string

前端 未结 1 746
轮回少年
轮回少年 2020-12-14 07:36

how do I remove the spaces, carriage returns from in between < and >

**START BELOW THIS LINE***


  admin         


        
1条回答
  •  长情又很酷
    2020-12-14 08:09

    If this is valid XML you could use the SaveOptions.DisableFormatting enumeration:

    string input = @"
      admin
      123abc..@!
      this is an item
    ";
    
    string result = XElement.Parse(input).ToString(SaveOptions.DisableFormatting);
    Console.WriteLine(result);
    

    0 讨论(0)
提交回复
热议问题