Mega Code Archive

 
Categories / C# / XML LINQ
 

XAttribute Class represents an XML attribute

using System; using System.Text; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass {     public static void Main()     {         StringBuilder output = new StringBuilder();         XElement root;         double dbl = 12.345;         XAttribute[] attArray = {             new XAttribute("Att4", 1),             new XAttribute("Att5", 2),             new XAttribute("Att6", 3)         };         DateTime dt = new DateTime(2006, 10, 6, 12, 30, 00);         root = new XElement("Root",new XAttribute("Att1", "Some text"),             new XAttribute("Att2", dbl),             new XAttribute("Att3", dt),             attArray         );         output.Append(root + Environment.NewLine);         Console.WriteLine(output.ToString());     } }