private void Bind()
        {
            string strLogPath = ConfigurationSettings.AppSettings["LOG_PATH"].ToString();
            if (strLogPath.Length > 0 && strLogPath[strLogPath.Length - 1] != '\\')
                strLogPath += '\\';

            string strXMLUrl = String.Format("{0}{1}.xml", strLogPath, DateTime.Now.ToString("yyyyMMdd"));

            string xmlContent = Common.Library.ReadFileAbsolute(strXMLUrl, ASCIIEncoding.GetEncoding("GB2312")).Replace("\r\n", "");

            StringReader strReader = new StringReader(xmlContent);
            DataSet ds = new DataSet();
            ds.ReadXml(strReader);
            DataTable dt = ds.Tables["item"];
        }

ds.ReadXml(xmlContent);直接读取要报错 有非法字符

所以在read之前用流来读一次

StringReader strReader = new StringReader(xmlContent);

问题结局。原理自己google吧。

相关文章:

  • 2021-08-11
  • 2022-12-23
  • 2021-10-25
  • 2021-11-08
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-11-30
  • 2021-10-05
  • 2021-06-16
  • 2021-09-25
相关资源
相似解决方案