【发布时间】:2020-11-09 09:05:00
【问题描述】:
我尝试使用 System.Xml.Linq 在所有文件上方创建以下行
<?xml version="1.0" encoding="utf-8"?>
这是代码
var firstLine = new XElement(
"?xml",
new XAttribute("version", "1.0"),
new XAttribute("encoding", "UTF-8"),
"?");
但运行后,我得到以下错误
result Message: System.Xml.XmlException: Name cannot begin with the '?' character, hexadecimal value 0x3F.
不知道有没有人知道如何解决这个问题?
【问题讨论】: