您的位置:首页 > 其它

Linq to xml: XDocument对象

2008-12-26 10:37 441 查看
XDocument d = new XDocument(

new XComment("This is a comment."),

new XProcessingInstruction("xml-stylesheet",

"href='mystyle.css' title='Compact' type='text/css'"),

new XElement("Pubs",

new XElement("Book",

new XElement("Title", "Artifacts of Roman Civilization"),

new XElement("Author", "Moreno, Jordao")

),

new XElement("Book",

new XElement("Title", "Midieval Tools and Implements"),

new XElement("Author", "Gazit, Inbar")

)

),

new XComment("This is another comment.")

);

d.Declaration = new XDeclaration("1.0", "utf-8", "true");

Console.WriteLine(d);

d.Save("c:/test.xml");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: