Creating an Element and Assigning a String As Its Value
using System; using System.Linq; using System.Xml.Linq; using System.Collections.Generic; class Program//ww w . ja v a2s.com { static void Main(string[] args){ XElement xFirstName = new XElement("FirstName", "Joe"); Console.WriteLine(xFirstName); } }
"Joe" is converted into an XText object, and that is added to the XElement object.