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

前端 未结 1 742
轮回少年
轮回少年 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 = @"<TestItem1Request>
      <Username>admin</Username>
      <Password>123abc..@!</Password>
      <Item1>this is an item</Item1>
    </TestItem1Request>";
    
    string result = XElement.Parse(input).ToString(SaveOptions.DisableFormatting);
    Console.WriteLine(result);
    
    0 讨论(0)
提交回复
热议问题