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");

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2022-02-27
  • 2021-07-11
猜你喜欢
  • 2021-06-29
  • 2022-12-23
  • 2022-03-07
  • 2021-09-02
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案