Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What could cause a blank XML file?

Tags:

.net

xml

.net-4.0

I'm using C# with .NET 4.0 and I'm trying to debug a rare problem with my application where sometimes the program will take my .xml file I read and write configuration settings to and will write a blank XML file.

The problem is I can't recreate it after exhaustive attempts to do so, so I thought I might make sure there isn't a known situation where the built in XmlDocument.Save() feature could result in a blank file.

The only way the XML file is ever modified is in memory using the built in XmlNode.AppendChild() and XmlNode.ReplaceChild() so I expect either the problem happens in one of those functions or on write to disk with the XmlDocument.Save() function.

like image 268
Kyle V. Avatar asked Jan 08 '13 14:01

Kyle V.


1 Answers

I found this thread. Especially the second last Answer might be worth a try. Quote:

A workaround which appears to work was to replace:

doc.Save("c:\temp\Output.xml")

with

IO.File.WriteAllText("c:\temp\Output.xml", doc.OuterXml);
like image 158
DasKrümelmonster Avatar answered Sep 23 '22 01:09

DasKrümelmonster