.net - Avoid the carriage return when writing InnerText in xml elements using System.Xml.XmlWriter -


I am using XmlWriter to save an XmlDocument in .Net. However all the elements of the interted surrounding carriage return are written with the characters.

I tried to use XmlWriterSettings to avoid writing those characters, but there is no luck yet.

Here is a piece of code used:

  XmlDocument outxml = new XmlDocument (); Outxml.AppendChild ....... XmlWriterSettings Set = New XmlWriterSettings (); Set up Encoding = encoding; Set up Indent = true; XmlWriter xwriter = XmlWriter.Create (file, set); Outxml.Save (xwriter); Xwriter.Close ();  

is like XML output:

   

must be similar to the required XML output:

  & lt; String id = "msierrXmlFileFailedSave" Overridable = "yes" & gt; Fehler beim Speichern der Einstellungen-Datei. & Lt; / String & gt;  

Is there any way to avoid writing those carriage returns inside the elements?

PD: I saw this issue, but the solution does not apply to this issue.

Thanks in advance.

Allen C

You will want to set the asset before calling Save. Another option is to use CDADA sections instead of internal text, where the text content of the elements must be protected.

From the document:

If PreserveWhitespace is right before the load or loadxil is called, white space nodes are preserved; Otherwise, if this property is false, then important white space is protected, there is no white space.

If the webspace is correct before saving, the white space in the document is preserved in the output; Otherwise, if this property is incorrect, then XmlDocument auto-indent output.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -