码迷,mamicode.com
首页 > Windows程序 > 详细

C#怎样处理xml文件的大于号和小于号等常用符号(xml符号引发的程序错误)

时间:2016-04-06 18:33:36      阅读:375      评论:0      收藏:0      [点我收藏+]

标签:

在程序中由xml配置而成的sql语句要转换为C#支持的sql语句

<settings>

<select> a.*</select>

<from>

(select top 1 (select COUNT(*) from OmsOrder as a left join SysState as b on (a.[State] = b.Value and b.StateType=‘StateDefault‘) where a.[State] = 0  and datediff(day,‘2016-03-25‘,a.[UpDate]) &lt;= 0 ) as Added,(select COUNT(*) from OmsOrder as a left join SysState as b on (a.[State] = b.Value and b.StateType=‘StateDefault‘) where a.[State] = 9  and datediff(day,‘2016-03-25‘,a.[UpDate]) &lt;= 0 ) as Passed,(select COUNT(*) from OmsOrder as a left join SysState as b on (a.[State] = b.Value and b.StateType=‘StateDefault‘) where a.[State] = -1  and datediff(day,‘2016-03-25‘,a.[UpDate]) &lt;= 0 ) as Droped, a.* from Omsorder as a ) a

</from>

<where></where>

<orderby> a.Name desc</orderby>

</settings>

原先这里是写成大于号和小于号

技术分享

程序进行转换时出错

技术分享

当我们需要通过xml格式处理sql语句时,经常会用到<=>>=等符号,但是很容易引起xml格式的错误,这样会导致后台将xml字符串转换为xml文档时报错,从而导致程序错误。

这样的问题在iBatiS中或者自定义的xml处理sql的程序中经常需要我们来处理。其实很简单,我们只需作如下替换即可避免上述的错误:

技术分享

详细解释在如下路径:

http://blog.csdn.net/hu_shengyang/article/details/8513655

 

C#怎样处理xml文件的大于号和小于号等常用符号(xml符号引发的程序错误)

标签:

原文地址:http://www.cnblogs.com/xielong/p/5360188.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!