当前位置:网站首页>![CDATA[]] and escape characters explained
![CDATA[]] and escape characters explained
2022-08-05 16:22:00 【HUAWEI CLOUD】
I. Introduction
At the DAO layer, SQL statements related to entity classes are usually configured in XML files, as follows:
<select id="queryUsrnmTypOprorder" parameterClass="java.util.HashMap"resultMap="queryCasprjstfsetListMap"> <![CDATA[ select a.usrnm, a.typ, a.oprorder from fset a inner join casprjstfapr using (stfaprid) where casprjstfapr.jugsumid =#jugsumid# and casprjstfapr.blnorg = #blnorg# and isvld = '1' order by a.typ asc,span> a.oprorder asc ]]> </select>The content contained by the tag ![CDATA[]] will be represented as plain text, for example, ![CDATA[]] means the text content "<".
This tag is used in xml documents, let's take a look at the use of escape characters.We know that in xml, characters such as "<", ">", "&" cannot be stored directly, otherwise an error will be reported during the xml syntax check. If you want to use these symbols in xml, you must escape them asEntities, such as "<", ">", "&", can be saved into the xml document.
The parser will automatically convert these entities back to "<", ">", and "&" when read by the program.For example: 
2. Attention
- There must be no spaces between escape sequence characters;
- Escape sequences must end with "
;"; - A single occurrence of "
&" is not considered the beginning of an escape; - Case sensitive.
In XML, characters that need to be escaped are:
But strictly speaking, only "<" and "&" are illegal in XML, the other three can exist legally, but, escaping them all is a good practice.
In any case, the characters before escaping and the characters after escaping will be parsed by the xml parser. For convenience, use ![CDATA[]] to includeContent not parsed by the xml parser.But it should be noted that:
- This section can no longer contain "
]]>"; - Nesting is not allowed; The
- ”
]]>” part cannot contain spaces or line breaks.
Finally, let's talk about the relationship between ![CDATA[]] and xml transfer characters. Do they seem to have duplicate functions?
3. Application scenarios and requirements
![CDATA[]]is not applicable in all cases, escape characters are OK;- It is verbose for short strings
![CDATA[]], but less readable for long strings with escape characters; ![CDATA[]]means that the xml parser ignores parsing, so it is faster.
边栏推荐
- 【翻译】EF Core 3.1.x, 5.x & 6.x Second Level Cache Interceptor
- playwright录制脚本
- 高数_证明_最值定理
- High Numbers_Proof_Intermediate Value Theorem
- uniapp中页面跳转的几种方式及生命周期(整理)
- leetcode:285. 二叉搜索树中的中序后继节点
- .NET WebShell 免杀系列之Unicode编码
- Monotonic Bounded Criterion for High Numbers_Prove_Limit Existence
- 学习笔记227—Word自动目录,目录编号后面有空格,怎样设置能去掉?
- 【R语言】对年龄数据进行清洗
猜你喜欢
随机推荐
高数_证明_极限存在的夹逼准则
【案例】3d相册
ECMAscript modules in browsers
城商行本地高可用建设实践与落地效果分享
机器人强化学习——COCOI: Contact-aware Online Context Inference for Generalizable Non-planar Pushing(21 ICRA)
基于consul的服务注册与消费案例
Redis - Talking about master-slave synchronization
国际站自养号补单
Basic Concepts in Network Communication
数据思维总结:
【案例】animation动画
【案例】animation动画曲线之steps的使用
傅里叶变换
【案例】3d导航
华为设备配置MSTP+VRRP组合组网
【案例】一个熊在跑的动画animation
关于将本地 SAP UI5 应用配置到本地 Fiori Launchpad 的技术实现深入讲解试读版
RestTemplate上传文件
The annual gas transmission volume of the West-East Gas Pipeline exceeds 100 billion cubic meters for the first time, and Tupu helps pipeline monitoring
【知识点】程序性能调优









