I use XDocument in LINQ to edit (paste) and save an XML document.
XDocument doc = XDocument.Load("c:\\sample.xml", LoadOptions.PreserveWhitespace); doc.Save("c:\\sample.xml",SaveOptions.DisableFormatting)
sample.xml before doc.Save:
<ELEMENT ATTRIB1="attrib1" ATTRIB2="attrib2" > value </ELEMENT>
sample.xml after doc.Save
<ELEMENT ATTRIB1="attrib1" ATTRIB2="attrib2"> value </ELEMENT>
As you can see, after ATTRIB1 and the space after ATTRIB2 there is double space in the source document. But these spaces were removed by linq when I call doc.save.
How to keep spaces inside a tag?
source share