zoukankan      html  css  js  c++  java
  • DataSet 读取xml 报错有非法字符

    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("
    ", "");
    
                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吧。

  • 相关阅读:
    js的同步和异步
    事件三
    事件2
    JS作用域题
    游戏之乐
    NSTimer(2)
    NSTimer
    理解 Objective-C Runtime
    iOS系统安全机制概览
    Which is the best of GCD, NSThread or NSOperationQueue?
  • 原文地址:https://www.cnblogs.com/huangyoum/p/4047709.html
Copyright © 2011-2022 走看看