Tuesday, December 18, 2012

XML/JavaScript Special Characters' Escape (Encode) Tool, Esp. for Adding AD Codes on Blogger

This XML/JavaScript Special Characters' Escape (Encode) Tool will automatically replace 5 predefined special characters in HTML/ JavaScript codes, so that they can be used in XML documents, esp. Blogger ( templates and widgets.

You can simply paste the JavaScript/HTML codes in following box, click on 'Convert', then copy the converted codes to use in XML documents (esp. Blogger template).

HTML/Javascript Codes:

If you are using Blogger ( 

In Google's Blogger ( platform, sometimes you get following error message (or similar) when trying to add ADsense codes or JavaScript codes (esp. JavaScript codes from 3rd party advertising (AD) company) to the template:

Error parsing XML, line 1205, column 91: The reference to entity "u" must end with the ';' delimiter.

I have talked about this issue in previous post . Why it happens is because Blogger template is using XML standard, which requires that, you can not use 5 special characters directly in the HTML/JavaScript codes, you have to use their entities' name.

I listed 2 ways to fix the problem. The first way is, replace the 5 special characters with their entities' name manually- which will take time if you get some long codes.

That's why I provide the above tool- to do the replacement automatically.


The 5 special characters:

 ' need to be replaced with '
 " need to be replaced with " 
need to be replaced with &
 < need to be replaced with &lt;
 > need to be replaced with &gt;

Wikipedia reference here.