How to comment a line of a XML file in C# with System.XML

Viewed 7057

I need to comment and uncomment the 4th line of this XML file using System.XML properties:

<?xml version="1.0" encoding="utf-8"?>
    <configuration>    
        <system.web>
            <customErrors mode="On" defaultRedirect="som_url_here" />
        </system.web>
    </configuration>

Desired output:

<!-- <customErrors mode="On" defaultRedirect="som_url_here" /> -->

It's possible to achieve this without using a file reader?

The node:

XmlNode xmlNodoCE = docWebConfig.DocumentElement.SelectSingleNode("system.web/customErrors");
3 Answers
Related