Friday, May 23, 2014

Fix Embed Code Error in Blogger Template

Well, an error message appears when adding HTML/Javascript code to Blogger Template is a quite often Blogger error. That's not mean there is a problem with your script or your template, it's just because Blogger Template Editor (actually it's a XML editor) is not completely compatible with special character in script. It can happen when you add Google Adsense code, html tag or any kind of javascript code.

Why Do Errors Happen?


The HTML Editor of Blogger template is actually an XML editor and every HTML code in it must satisfies XML structure. With HTML, some error can be ignored and let's browser fix itself (browsers like Firefox, Chrome will automatically can fix HTML error and display exactly what's the coder wanted). But not with XML.

Every XML tag need a corresponding close tag and some special characters like &, <, " will make XML tag does not close properly. And that's why the parsing errors happen. Some kinds of parsing errors:

Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.

This is an old error message and you might not see it in Blogger nowaday, I guess. This error appears when you try adding Google Adsense code to your template. That's because Blogger XML did not accept the <script></script> tag.

“Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The processing instruction target matching “[xX][mM][lL]” is not allowed.”

This is also an old error message. It happened when you try to embed code from Adveritising Network like Bidvertiser, Chitika or Adbrite etc.

Error parsing XML, line 8, column 82: The reference to entity "xxx" must end with the ';' delimiter 

Finally, the typical blogger error message that you do encounter very often. With xxx is the error entity with special character right before it.
For example, this error happens when I add Google Font code to my template. The error at this picture below because of the & character before subset entity.
Blogger Parsing XML Error
Blogger Parsing XML Error
And this error when I added Facebook Javascript SDK, because of & character before appID.

Blogger XML Parsing Error
Blogger XML Parsing Error

How to fix this kind of error?


The error happens because of special character, therefore we need to change this character into xHTML entity.
The easiest way to fix it is use HTML Encoder/Converter from Howeblog to automatically convert special characters to xHTML entities.
How to use HTML Encoder/Converter
  1. Go to HTML Encoder/Convert Tools
  2. Paste your code in the first text box
  3. Select all the check box.
  4. Click Convert
  5. Get your code at second text box, copy and paste it in Blogger template editor.
How to use HTML Converter/Encoder

Does It Affect Your Original Code?

Not at all! This tool just converts special character into a valid xHTML entity, beside that, every line of code is kept. After add converted code to your template, , you can test by viewing your blog, then press Ctrl + U (View Source), find your code position and you will notice the converted code just like the original code.


5 comments:

  1. Hello Admin Please Tell Me How to Fix this. Google Ad Service is Disable on My Blog. Reason is

    MODIFIED ADS: Publishers are not permitted to alter the behavior of Google ads in any way. This includes resizing ad frames to cut off parts of ads or hiding the Ads by Google moniker.

    ReplyDelete
  2. When we look around us- we see a genera misconception regarding education, we seem to believe it is restricted in the schools and institutes. Very often we tend to think of education in its real spirit and essence which is getting research paper writing service enough knowledge to get the inner peace of life.

    ReplyDelete
  3. nice post, we are the quality website development company that make effective and cheap websites by Indian company is professional developers, website development company in India

    ReplyDelete
  4. Nice articel, This article help me very well. Thank you. Also please check my article on my site Know All About Web Tutorial.

    ReplyDelete
  5. Techgropse is a well-known healthcare application development company that provides specialized healthcare applications and is one of the leading healthcare app development companies in the region. We aim to make healthcare applications accessible to all, with incredible solutions.

    Learn more - https://www.techgropse.com/healthcare-app-development

    ReplyDelete