请教如何生成如下格式xml
<?xml version="1.0" encoding="UTF-8"?>
<DATABASES version="1.1">
<FTK version="4.0">
<defaultDatabase>
<host>127.0.0.1</host>
<port>5432</port>
<dbsystem>Postgres</dbsystem>
</defaultDatabase>
<database>
<host>localhost</host>
<port>5432</port>
<dbsystem>Postgres</dbsystem>
</database>
<database>
<host>127.0.0.1</host>
<port>5432</port>
<dbsystem>Postgres</dbsystem>
</database>
</FTK>
</DATABASES>
------解决方案--------------------
http://www.cnblogs.com/jasmine_xm/archive/2010/08/29/1811984.html
------解决方案--------------------我去,什么破代码模板,重新贴一次
static void Main(string[] args)
{
XElement x = new XElement("DATABASES", new XAttribute("version", "1.1"),
new XElement("FTK", new XAttribute("version", "4.0"),
new XElement("defaultDatabase",
new XElement("host", "127.0.0.1"),
new XElement("port", "5432"),
new XElement("dbsystem", "Postgres")
),
new XElement("database",
new XElement("host", "127.0.0.1"),
new XElement("port", "5432"),
new XElement("dbsystem", "Postgres")
),
new XElement("database",
new XElement("host", "127.0.0.1"),
new XElement("port", "5432"),
new XElement("dbsystem", "Postgres")
)
)
);
Console.WriteLine(x.ToString());
Console.Read();
}