Question: I'm having trouble reading an XML file and adding nodes to it. Well not exactly.. adding nodes works fine, but the source XML File contains some Lines containing `&quot;`

After Saving my xmlDocument those `&quot;` parts are converted to `"`

How can i prevent c# from converting `&quot;` to `"` because the application that loads the xml file needs those `&quot;` marks

Example Line:

`<item name="Description">DBName "xyz"</item>`

Answer: 
You don't need to encode quotation marks in elements, only in attributes. So:

```
<item name="Description">DBName &quot;xyz&quot;</item>

```

is unnecessary, you can just use:

```
<item name="Description">DBName "xyz"</item>

```

It seems XmlDocument.Load() understands what you mean when you unnecessarily put encoded quotations marks (&quot;) in an element and that by default XmDocument.Save() replaces them with unencoded quotation marks (").

You'll notice exactly the same behaviour if your source is:

```
<item name="Description">DBName &#34;xyz&#34;</item>

```

where " is the XML character reference for "

<https://stackoverflow.com/a/150441/283787> explains: *" is not a character that must be encoded in element data.*

If you want to presetve whitespace, simple add the following line of code:

```
doc.PreserveWhitespace = true;

```
Thanks guys, i really didn't need to escape those quotes. The Problem is that document.save alters the xml output and so the target application can't properly read the xml.

Example:

`<profile>
 <list name="">
 <item name="FileVersion">0.88</item>
 <item name="ID">xyz</item>`

Turns into

`<profile>
 <list name="">
 <item name="FileVersion">0.88</item>
 <item name="ID">xyz</item>`

There are more spaces before the node

and if there are empty values

`<item name="Value"></item>`
turns into

`<item name="Value">
 </item>`