问题描述
我有一个XML描述符文件,其中包含以下属性规范:
I have an XML descriptor file containing attribute specifications such as:
<attribute
name="abc"
description="xyz e.g. <br> with a new line">
...
</attribute>
这些XML描述符被groovy脚本解析,以产生HTML文档(除其他外) :
These XML descriptors are parsed by a groovy script to produce HTML documentation (among other things) along the lines of:
<table>
<tr><th>Name</th><th>Description</th></tr>
<tr><td>abc</td><td>xyz e.g. <br>with a new line</td></tr>
</table>
我的问题是我必须在XML中将HTML实体显示为字符文字?例如小于号,例如:
My question is what do I have to put in the XML to display HTML entities as character literals? e.g. A less than sign, such as:
<table>
<tr><th>Name</th><th>Description</th></tr>
<tr><td>abc</td><td>You must supply a <port number></td></tr>
</table>
(groovy脚本没有对XML描述进行处理 - 只是将它打印到HTML文件中。)
(The groovy script does no processing on the XML description - just prints it into the HTML file.)
推荐答案
在HTML实体中跳过&符号,以获得以下内容:
Escape the ampersands in the HTML entities so you get the following:
<attribute
name="abc"
description="You must supply a &lt;port number&gt;">
...
</attribute>
Groovy脚本将会看到该属性值:
The attribute value will then be seen by the Groovy script as:
You must supply a <port number>
这篇关于我可以使用XML转义HTML实体吗?这样它们就可以在网页上直接显示了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!