【问题标题】:encoding' is an unexpected token. the expected token is '?>' when reading XML data into DataSetencoding' 是一个意外的标记。将 XML 数据读入 DataSet 时,预期的标记是 '?>'
【发布时间】:2013-09-03 18:31:40
【问题描述】:

当我的 xml 文件数据使用 Readxml 读入 DataSet 时,我遇到了运行时错误。

"encoding' 是一个意外的标记。预期的标记是 '?>'"

我的 C# 代码是:

XmlReader xmlFile = XmlReader.Create("WH7_Inventory.xml", new XmlReaderSettings());            
DataSet ds = new DataSet();
ds.ReadXml(xmlFile);

我的xml文件是

<?xml version="1.0" encoding="UTF-8" standalone="true"?>

【问题讨论】:

    标签: c# xml


    【解决方案1】:

    standalone 的属性值不正确。它应该是yesno

    Standalone Document Declaration

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    

    假设这是您在 XML 文档中的全部内容,因为您没有根元素,您可能仍然会收到错误。

    【讨论】:

    • 很抱歉投了反对票。负责的用户已被警告,脚本应在今晚反转所有这些。如果他们明天还没有离开,请告诉我,我会联系社区团队。
    猜你喜欢
    • 1970-01-01
    • 2018-10-24
    • 2021-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-27
    • 1970-01-01
    相关资源
    最近更新 更多