繁体   English   中英

转义xml中的特殊字符

[英]escape special character in xml

我在以下xml文件中运行此查询:

<?xml version="1.0" encoding="UTF-8"?>
    ..
    ...
    <query> 
         update tableX set colName='$ClassService.getParameter(\"param1\")$' where id = '0'
    </query>
    ...

我收到以下错误:

ERROR]:发生异常,终止。 java.lang.IllegalArgumentException:异常解析或评估ClassService.getParameter(\\“param1 \\”)

如何逃脱“正确?

那么只使用CDATA部分呢?

 <![CDATA[
 Within this Character Data block I can
 use double dashes as much as I want (along with <, &, ', and ")
 *and* %MyParamEntity; will be expanded to the text
 "Has been expanded" ... however, I can't use
 the CEND sequence (if I need to use it I must escape one of the
 brackets or the greater-than sign).
 ]]>

或者这不符合您的要求?

所以它看起来类似于:

<?xml version="1.0" encoding="UTF-8"?>
..
...
<query> 
     <![CDATA[
     update tableX set colName='$ClassService.getParameter(\"param1\")$' where id = '0'
     ]]>
</query>
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM