title: Comment xml elements programmatically
body: <p>I have an xml file like below,</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;property&gt;
        &lt;name&gt;name&lt;/name&gt;
        &lt;value&gt;dinesh&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
        &lt;name&gt;city&lt;/name&gt;
        &lt;value&gt;Delhi&lt;/value&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>My requirement is I need to comment / uncomment properties programmatically at runtime based on property's name like below; </p>
  
  <pre><code>&lt;configuration&gt;
      &lt;!-- &lt;property&gt;
        &lt;name&gt;name&lt;/name&gt;
        &lt;value&gt;dinesh&lt;/value&gt;
      &lt;/property&gt; --&gt;
      &lt;property&gt;
        &lt;name&gt;city&lt;/name&gt;
        &lt;value&gt;Delhi&lt;/value&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Is there any direct way to achive this via XDocument / XmlDocument traversal? I just gone through code like below from <a href="https://stackoverflow.com/questions/21580537/how-to-comment-an-xmlelement-using-c">this</a> question, </p>
  
  <pre><code>XmlComment DirCom = doc.CreateComment(XmlElementName.OuterXml);
  doc.InsertAfter(DirCom, XmlElementName);    
  doc.RemoveChild(XmlElementName)
  </code></pre>
  
  <p>Is the above code usage a right approach?</p>