如何在x#代码中将xml扁平化为一行?
之前:
<CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> </CATALOG>
后:
<CATALOG><CD><TITLE>Empire Burlesque</TITLE><ARTIST>Bob Dylan</ARTIST>COUNTRY>USA</COUNTRY>....
假设您能够使用LINQ to XML,并且XML当前位于文件中:
原文链接:https://www.f2er.com/xml/292342.htmlXDocument document = XDocument.Load("test.xml"); document.Save("test2.xml",SaveOptions.DisableFormatting);