using System;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//保存
XElement xel1 = XElement.Parse(@"
<Root>
<Persons>
<Person Id='1'>
<Name>Huang Cong</Name>
<Sex>男</Sex>
</Person>
</Persons>
</Root>");
//保存至test1.xml文档中
xel1.Save("test1.xml");
XElement xel2 = new XElement(
new XElement("Root",
new XElement("Child1", 1),
new XElement("Child2", 2))
);
//保存至test2.xml文档中
xel2.Save("test2.xml");
}
}
}