Add serveral XML attribute to Element in CSharp
Description
The following code shows how to add serveral XML attribute to Element.
Example
// w w w . j a v a 2 s . c o m
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());
}
}