aepheus
aepheus

Reputation: 8187

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>

Upvotes: 0

Views: 379

Answers (3)

rhino
rhino

Reputation: 13881

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.

Upvotes: 2

Lekensteyn
Lekensteyn

Reputation: 66415

The correct XML way is to use CDATA section identifiers:

<script type="text/javascript">//<![CDATA[
/* code */
//]]></script>

Upvotes: 0

HoLyVieR
HoLyVieR

Reputation: 11134

If you are using tag in strings you can do this :

 var yourHTML = "<STR_PROCESSING>YourData<" + "/STR_PROCESSING>";

Upvotes: 0

Related Questions