Search code examples
htmlxmlw3c-validationscript-tag

Page not validating because of xml in a script tag


I'm trying to get a page to validate (http://validator.w3.org) and it complains about some xml I have inside a script tag.

How can I resolve this? Am I supposed to have something around the content of my script tag saying "don't look at me"?

Line 68, column 114: end tag for element "STR_PROCESSING" which is not open

>Processing....</STR_Processing>

Code:

<script type="text/javascript" defer="defer">
var sML_XML='<STR_Processing>Processing....</STR_Processing><STR_OK>...';
</script>

Solution

  • You have to place a backslash (\) before the slashes, when it is in a script.
    Look here: http://www.htmlhelp.com/tools/validator/problems.html#script

    For example:
    var test="<b>something<\/b>";
    instead of:
    var test="<b>something</b>";

    This should validate with no errors.