Replace an Element

 
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

class Program
{
    static void Main()
    {
        XElement items = XElement.Parse("<items><one/><two/><three/></items>");
        items.FirstNode.ReplaceWith(new XComment("One was here"));

        Console.WriteLine(items);
    }
}
  

The output:

<items><!--One was here--><two /><three /></items>
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.