简体   繁体   中英

escape special character in xml

I run this query in the following xml file:

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

I get the following error:

ERROR]: Exception occurred, terminating. java.lang.IllegalArgumentException: Exception parsing or evaluating ClassService.getParameter(\\"param1\\")

How to escape " correctly?

What about just use a CDATA-section for this?

 <![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).
 ]]>

Or does this not fit your requirement?

So that it will look similar to this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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