Set the value of an element in CSharp

Description

The following code shows how to set the value of an element.

Example


using System;//ww  w  . j  a  v  a  2 s.com
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;


public class MainClass{
   public static void Main(){

        XElement root = new XElement("Root",
            new XElement("Child", "child content")
        );
        root.SetValue("new content");
        Console.WriteLine(root);

   }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style