Special Character Must Be Replaced"

From Documentation
(Created page with '{{ZKDevelopersGuidePageHeader}} XML use <tt><''element-name''></tt> to denote an element, so you have to replace special characters. For example, you have to use <tt>&lt;</t…')
 
m (correct highlight (via JWB))
 
Line 1: Line 1:
 
{{ZKDevelopersGuidePageHeader}}
 
{{ZKDevelopersGuidePageHeader}}
  
XML use <tt><''element-name''></tt> to denote an element, so you have to replace special characters. For example, you have to use <tt>&amp;lt;</tt> to represent the <tt><</tt> character.
+
XML use <code><''element-name''></code> to denote an element, so you have to replace special characters. For example, you have to use <code>&amp;lt;</code> to represent the <code><</code> character.
  
  
Line 38: Line 38:
 
| Required only if use it in a XML attribute's value
 
| Required only if use it in a XML attribute's value
 
|}
 
|}
Alternatively, you could tell XML parser not to interpret a piece of text by using <tt>CDATA</tt> as the following.
+
Alternatively, you could tell XML parser not to interpret a piece of text by using <code>CDATA</code> as the following.
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 51: Line 51:
 
</source>
 
</source>
 
   
 
   
It is suggested to always add <tt><![CDATA[    ]]></tt> inside your <tt><zscript> </zscript></tt>. Thus you don't have to worry about escape sequences for special characters like "&", "<". In addition, the code is much easier to read and maintain.
+
It is suggested to always add <code><![CDATA[    ]]></code> inside your <code><zscript> </zscript></code>. Thus you don't have to worry about escape sequences for special characters like "&", "<". In addition, the code is much easier to read and maintain.
  
  
 
{{ ZKDevelopersGuidePageFooter}}
 
{{ ZKDevelopersGuidePageFooter}}

Latest revision as of 10:36, 19 January 2022

Special Character Must Be Replaced


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


XML use <element-name> to denote an element, so you have to replace special characters. For example, you have to use &lt; to represent the < character.


Special Character
Replaced With
<
&lt;
>
&gt;
&
&amp;
"
&quot;
'
&apos;
\t (TAB)
&#x09;
Required only if use it in a XML attribute's value
\n (Linefeed)
&#x0a;
Required only if use it in a XML attribute's value

Alternatively, you could tell XML parser not to interpret a piece of text by using CDATA as the following.

 <zscript>
 <![CDATA[
 void myfunc(int a, int b) {
     if (a < 0 && b > 0) {
         //do something
     }
 ]]>
 </zscript>

It is suggested to always add <![CDATA[ ]]> inside your <zscript> </zscript>. Thus you don't have to worry about escape sequences for special characters like "&", "<". In addition, the code is much easier to read and maintain.



Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.