How do I have to change this XML string so that XDocument.Parse reads it in?

前端 未结 3 2421
攒了一身酷
攒了一身酷 2021-02-20 13:25

In the following code, I serialize an object into an XML string.

But when I try to read this XML string into an XDocument

3条回答
  •  名媛妹妹
    2021-02-20 14:04

    It's because the data contains the unicode or utf8 BOM marks at the start of the stream.

    You need to skip past any Byte Order Marks in the stream - you can identify these from the System.Text.Encoding.GetPreamble() method.

提交回复
热议问题