Parsing xml string to an xml document fails if the string begins with <?xml… ?> section

前端 未结 5 914
闹比i
闹比i 2021-01-01 11:41

I have an XML file begining like this:




        
5条回答
  •  一整个雨季
    2021-01-01 12:13

    Why bothering to read the file as a byte sequence and then converting it to string while it is an xml file? Just leave the framework do the loading for you and cope with the encodings:

    var xml = XDocument.Load("test.xml");
    

提交回复
热议问题