Re: xml parsing error for < character

* "Dave Raggett" <dsr@w3.org> wrote:
| Unfortunately, current HTML browsers don't recognize CDATA marked
| sections, and furthermore they expect script elements to have
| CDATA content, and hence expect < and & to be unescaped.

| The XHTML 1.0 standard therefore recommends you move your scripts
| to external files. The onmouseover and other event attributes
| are however ok, as browsers will deal with entities in attribute
| values.

| I am uncertain as what HTML Tidy should do about this problem.
| If it wraps the contents of a script element in a CDATA marked
| section, it will stop the pages working in existing browsers.

This workaround should meet all possible needs:

<script type="text/javascript">
<!-- --> <![CDATA[ /> <!--

document.write("<p>foobar<\/p>");

// --> <! ]]>
</script>

regards,
--
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981ASK ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote +{i}

Received on Wednesday, 6 September 2000 15:30:29 UTC