【发布时间】:2021-07-01 18:46:42
【问题描述】:
我收到以下错误(我在其他 SO 帖子中看到):
There is no Unicode byte order mark. Cannot switch to Unicode.
我在用户交换的其他 SO 帖子上看到:
<?xml version="1.0" encoding="utf-16"?>
到:
<?xml version="1.0" encoding="utf-8"?>
我无法即时更新所有导入的 XML 来切换它,所以我想知道如何以编程方式进行。我有以下代码,其中
private static string ParseXML(Stream xmlSteam)
{
using (var xmlReader = XmlReader.Create(xmlSteam))
{
// Errors out here with the unicode exception being caught
while (xmlReader.Read())
我正在尝试修复它,以便它能够读取和解析 XML。
【问题讨论】:
标签: .net xml .net-core xmlreader .net-core-3.1