Can I Escape HTML Entities In XML So That They Are Displayed Literally On A Web Page?
I have an XML descriptor file containing attribute specifications such as: ...
Solution 1:
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>
The attribute value will then be seen by the Groovy script as:
You must supply a <port number>
Solution 2:
You can simply replace '&' to '&
' to work around it. Here is the code:
<div id="d"></div>
<script type='text/javascript'>
var str = "<table><tr><th>Name</th><th>Description</th></tr><tr><td>abc</td><td>You must supply a &lt;port number &gt;</td></tr></table>";
document.getElementById('d').innerHTML = str;
</script>
Post a Comment for "Can I Escape HTML Entities In XML So That They Are Displayed Literally On A Web Page?"