开发者

How to remove white spaces in XML Document in C#

开发者 https://www.devze.com 2023-03-24 14:32 出处:网络
could anyone please help me on how to remove all the white spaces between XML tags as shown below: <?xml version=\"1.0\"?>

could anyone please help me on how to remove all the white spaces between XML tags as shown below:

<?xml version="1.0"?>
<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget 开发者_开发知识库me this weekend!</body>
</note>

To:

<?xml version="1.0"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>

Thank you heaps.


You can use XLinq:

XElement.Parse(str).ToString(SaveOptions.DisableFormatting)
0

精彩评论

暂无评论...
验证码 换一张
取 消