How to print <?xml version=“1.0”?> using XDocument

后端 未结 6 1032
暗喜
暗喜 2020-11-29 02:16

Is there any way to have an XDocument print the xml version when using the ToString method? Have it output something like this:

         


        
6条回答
  •  执笔经年
    2020-11-29 02:54

    Just type this

    var doc =
        new XDocument (
            new XDeclaration ("1.0", "utf-16", "no"),
            new XElement ("blah", "blih")
        );
    

    And you get

    
    blih
    

提交回复
热议问题