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 ...
随机推荐
- ORACLE UNDO
UNDO 数据操纵 数据操纵语言(DML)由以下SQL语句组成: INSERT,DELETE,UPDATE,MERGE DML始终作为事务处理的一部分执行,它可以: 使用Rollback命令执行回退 ...
- 《Nginx - 指令》- Rewrite/If/Set
一:Rewrite - 概述 - flag 作用 - last / break 实现对 Url 的重写. - redirect / permanent 实现对 Url 的重定向. - 使用范围 - s ...
- Python一个文件调用另外一个文件的方法
from common.Log import MyLog as Log 写法不完善修改为 import common.Log.MyLog as Log 即可
- word2vec训练好的词向量
虽然早就对NLP有一丢丢接触,但是最近真正对中文文本进行处理才深深感觉到自然语言处理的难度,主要是机器与人还是有很大差异的,毕竟人和人之间都是有差异的,要不然不会讲最难研究的人嘞 ~~~~~~~~~~ ...
- 关于话题模型(topic model)的一些思考
最近在分析知乎的‘问题’文本所属的话题,用python提取,实现了LSTM和LDA模型在这个方面的应用,但是效果不是很理想,一个是这些文本属于短文本,另外用来分析的文本本身包含多个领域的问题,并且数量 ...
- Innodb buffer 相关参数
buffer相关参数: show GLOBAL VARIABLES LIKE 'innodb_buffer_pool_instances'; show GLOBAL VARIABLES LIKE 'i ...
- CSS学习(二)
<!DOCTYPE html> <html> <head> <meta charset="{CHARSET}"> <title ...
- sql server系统存储过程大全
关键词:sql server系统存储过程,mssql系统存储过程 xp_cmdshell --*执行DOS各种命令,结果以文本行返回. xp_fixeddrives --*查询各磁盘/分区可用空间 x ...
- (1)DBA查询:数据库
1.数据库状态:[1]sys.databases [2]exec sp_spaceused 2.数据文件状态:[1]sys.master_files [2]查看ldf与mdf:sp_helpfil ...
- vim常用指令整理小结
启动Vim后,默认是在 Normal 模式下,但是我们有时不知道是在编辑模式还是normal模式,按ESC键就可以返回normal模式.因为所有的命令都需要在Normal模式下使用,所以建议多按几下E ...