DataSet 读取xml 报错有非法字符
private void Bind()
{
string strLogPath = ConfigurationSettings.AppSettings["LOG_PATH"].ToString();
if (strLogPath.Length > && strLogPath[strLogPath.Length - ] != '\\')
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吧。
DataSet 读取xml 报错有非法字符的更多相关文章
- 使用java2Word生成Word文档打不开报错 存在非法字符xml
今天也不知道是该吐槽Java2word还是我的eclipse,总之就是使用Java2Word生成文档的时候文档生成没问题,但是生成的Word文档打不开还报错,存在非法字符xml,好扎心.终于找到了解决 ...
- Python读取xml报错解析--ExpatError: not well-formed (invalid token)
xml文件内容如代码所示存入的名字为login.xml: <?xml version="1.0" encoding="utf-8"?> <in ...
- xml报错 Parse Fatal Error :在实体引用中,实体名称必须紧跟在'&'后面
修改jndi配置文件中的密码后,重启tomcat报错如下 实际问题是xml中默认’&’是非法字符,用 & 替代
- android 程序中res/values-v14/styles.xml报错的解决办法
从旧的ADT迁移的新的ADT时, android 程序中res/values-v14/styles.xml报错: error: Error retrieving parent for item: No ...
- 新建maven工程时pom.xml报错
新建maven工程时,pom.xml报错:第一行报如下错误:multiple annotations found at this line后添加org.eclipse.m2e相关的plugin配置后, ...
- eclipse中Maven项目pom.xml报错:com.thoughtworks.xstream.io.HierarchicalStreamDriver
eclipse中创建Maven项目时 pom.xml报错:com.thoughtworks.xstream.io.HierarchicalStreamDriver 解决方案1.在pom文件中加入mav ...
- idea工程中web.xml报错Servlet should have a mapping
搭建ssm工程过程中web.xml报错:Servlet should have a mapping ....但是mapping已经配置好了...如下图: 搜索无果,后来发现是工程的web.xml位置配 ...
- 【python】python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte sequence
python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte ...
- applicationContext.xml报错org.springframework.orm.hibernate3.LocalSessionFactoryBean not found
applicationContext.xml报错org.springframework.orm.hibernate3.LocalSessionFactoryBean not found 解决办法: 1 ...
随机推荐
- 【Python全栈-JavaScript】JavaScript入门
JavaScript基础知识点 一.JavaScript概述 参考:http://www.w3school.com.cn/b.asp JavaScript的历史 1.1992年Nombas开发出C-m ...
- WCF访问超时:HTTP 请求已超过xx:yy分配的超时。为此操作分配的时间可能是较长超时的一部分。
在服务端设置时间长些 <client> <endpoint address="http://43.98.49.189:5700/UPJWCFServcie.svc" ...
- centos中文语言安装
1.查看当前使用的系统语言 #echo LANG 2.查看系统是否安装中文 #locale 如有zh_cn,表示已经安装了中文语言 3.安装中文 #yum groupinstall chinese-s ...
- 安装sqlserver2008中出现的问题小结
安装完sqlserver2008时报了几个错,但是好歹装上了,但是我想使用sa用户登录,给我出现了这么一个错 标题: 连接到服务器------------------------------ 无法连接 ...
- Spring对Bean装配详解
1.Spring提供了三种装配bean的方式: 2.自动装配bean: 3.通过Java代码装配bean 4.通过XML装配bean 前言:创建对象的协作关系称为装配,也就是DI(依赖注入)的本质.而 ...
- JavaScript学习(八)
- asp.net乱码问题
1.html文件乱码 html文件是有编码方式的,比如"UTF-8"."GB2312". A.VS中在文件选项,文件另存为...,保存右边的下拉框编码保存... ...
- NYOJ 单词拼接
# include<iostream> # include<string> # include<string.h> # include<queue> # ...
- Android使用SpannableString设置多样式文本
Android将一行文本设置为多种样式时,可以使用 SpannableString 来实现 private void setTips(){ String big = "大字深色"; ...
- jode反编译软件
1.下载 http://jode.sourceforge.net/(官网) https://sourceforge.net/projects/jode/files/(下载地址) 2.使用 下载的jod ...