XML Extra free space

Good day, in general is a problem, I work with XML through C# XMLdocument, after saving that "document", there is such a thing: 

<Name></Name>

After saving:

<Name>
</Name>

How to remove extra spaces?  I've tried: doc.PreserveWhitespace=true;  before saving and before loading. The result is not one that removes all spaces. XML document (large volume) become visually unreadable. I have already tried, same result. And need Encoding windows-1251 Why XmlDocument do this bad thing? That free or whitespace important for me and my "program". the problem is solved. thank you all

Answers


It can be done. You've got to help control the formatting options when you save the document:

XmlDocument doc = new XmlDocument();

using (var wr = new XmlTextWriter(fileName))
{
    wr.Formatting = Formatting.None;
    doc.Save(wr);
}

Or you can fine-tune it further with XmlWriterSettings:

var settings = new XmlWriterSettings
{
    Indent = false,
    NewLineChars = String.Empty
};
using (var wr = XmlWriter.Create(fileName, settings))
{
    wr.Formatting = Formatting.None;
    doc.Save(wr);
}

Need Your Help

Javascript library for syntax-highlighting syslog text logs?

javascript syntax highlighting syslog

I'm display some plain-text syslog output on a web page. I'd really like to pretty-print it, highlighting dates and hostnames. Are there any javascript syntax highlighting libraries which come with

When I add new testers to TestFlight do I have to put out a new build for them to be "notified"?

ios xcode itunesconnect testflight beta

I added around 50 new testers to my external testing via TestFlight in iTunes Connect tonight, but a few hours later none of them have received an email, and the "status"/iOS column in the users li...