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

后端 未结 6 1079
暗喜
暗喜 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:37

    The easier way is:

    var fullXml = $"{xDocument.Declaration}{xDocument}";
    

    If your xDocument.Declaration is empty, just add it.

提交回复
热议问题