January 29th, 2009, 07:06 AM
I am having trouble with XML in C# and I am now searching for a solution for several days now. Perhaps you can help me.
This is my situation:
I am writing an C# Application in which I have to edit an XML file. This application will only do very small changes. The XML file is also altered by several other sources (other applications, scripts, and even manual user input. It's a real nightmare!) but, thank god, not at the same time. Nevertheless, my application must preserve the file as good as it can, since the file is also subjected to a version control system (svn in my case). So I must not alter parts of the file where i did not change the semantic content!
This is my current approach:
So I thought: Yeah, the XML DOM will do the job.
So, I am using an XmlDocument object, I set doc.PreserveWhitespace to true and use Load and Save for the IO.
This is my problem:
However, this does not preserve the whitespaces between the Attributes inside a tag!
<TAG attr="value" >
This is not good for me.
So, is there any idea how I can preserve these whitespaces too. Of course, I could do it manually, but I would like a more elegant solution.
I hope you can help me.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.