When we need to process SQL statements in XML format, we often use symbols such as <, <=,>,>= and so on, but it is easy to cause errors in XML format, which causes the background to convert XML strings to XML document times, which can lead to program errors.
Such problems often need us to deal with in Ibatis or in a custom XML-processing SQL program. In fact, it is very simple, we just need to replace the following to avoid the above error:
Original symbol |
< |
<= |
> |
>= |
& |
‘ |
" |
Replace symbol |
< |
<= |
> |
>= |
& |
' |
" |
Bad XML format:
[HTML]View Plaincopy
- <? XML version= "1.0" encoding="GBK"?>
- <queryform token="32sdfj-349sfdnfs32-fsdf348imfg323-df34" tablename="Hsy_t_customer" pagesize= "pageno=" 1 " ordercolumn= " "Ordertype=" ">
- <sqlcondition> and start_date >= to_date (' 2013-01-01 ', ' yyyy-mm-dd ') and start_date <= To_date (' 2013-01-30 ', ' yyyy-mm-dd ') </sqlcondition>
- </queryform>
Error in Altova XMLSpy tool, XML does not conform to format requirements.
The correct XML format:
[HTML]View Plaincopy
- <? XML version= "1.0" encoding="GBK"?>
- <queryform token="32sdfj-349sfdnfs32-fsdf348imfg323-df34" tablename="Hsy_t_customer" pagesize= "pageno=" 1 " ordercolumn= " "Ordertype=" ">
- <sqlcondition> and start_date >= to_date (' 2013-01-01 ', ' yyyy-mm-dd ') and start_date <= To_date (' 2013-01-30 ', ' yyyy-mm-dd ') </sqlcondition>
- </queryform>
MyBatis SQL XML processing less than and greater than sign