我将调用一个 WebService 并从 WebMethod 获取一个字符串返回。该字符串是作为 XML 序列化的对象,应使用 System.Xml.XmlSerializer 进行反序列化。
我的问题是第一行指示文档采用 UTF-16 编码:
因此,在反序列化时,我遇到了错误:
我的问题是第一行指示文档采用 UTF-16 编码:
<?xml version="1.0" encoding="utf-16"?>
因此,在反序列化时,我遇到了错误:
There is an error in XML document (0, 0).
使用string.Replace("utf-16", "utf-8")确实可以工作,但必须有一种清洁的方法让XmlSerializer知道?