我希望在寫入文檔之前,在下面的XML中刪除所有空行。這可能有助於瞭解我使用XPathNavigator類的.DeleteSelf()方法在(以及僅留下空行)之前擺脫了不需要的節點。如何從使用C#的XML文檔或節點中刪除空白行?
<Person xmlns="http://someURI.com/something">
<FirstName>Name1</FirstName>
<MiddleName>Name2</MiddleName>
<LastName>Name3</LastName>
</Person>
你試圖加載這樣的內容轉換成'XDocument'然後將其保存爲XML文件? –
參考這篇文章http://stackoverflow.com/a/6480081/1513471 –
可能重複[什麼是最簡單的方法來從XmlDocument獲取縮進XML換行符?](http://stackoverflow.com/questions/) 203528/what-is-the-simple-way-to-in-indented-xml-with-line-breaks-from-xmldocument) – har07