April 26, 2017

(Solved) Error parsing XML: The reference to entity "version" must end with the ';' delimiter

Are you confused with the error, your template could not be parsed as it is not well-formed by blogger template when adding login script or like box script from Face Book develper page? Today i am going to share an easy way to correct it. This error is frequently seen when adding the character "&" into new blogger templates. This "&" is usually seen when copying login script or like box script from Face book developer page to your blogger template.
The original script from Facebook developer page is as follows;

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9&appId=630535786999761";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script> 

After pasting the script into the template and saving it, you will see this error "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 reference to entity "version" must end with the ';' delimiter. OR you will get this error, "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 entity name must immediately follow the '&' in the entity reference". So to correct this error you should not use "&" as a character in blogger templates when adding scripts but replace "&" to &amp; tag. When using ampersand within an attribute value it should always be written using amp; tag.

Facebook Modified Script 2.3 - Have an App ID

<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = &quot;//connect.facebook.net/en_US/all.js#xfbml=1&amp;appId=536279186383983&quot;;
  fjs.parentNode.insertBefore(js, fjs);
}(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));</script>

You should replace the "536279186383983" to your appId.
Add this script to above "< / head >" (without spaces) tag. You can find it by CTRL+F and typting this tag on blogger template.

To know more about parsing xml, you can check out my new post of parsing xml error messages in blogger templates.


Update on New Facebook Modified Script 2.9 - Have an App ID

<script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = &quot;//connect.facebook.net/en_US/all.js#xfbml=1&amp;appId=630535786999761&quot;; fjs.parentNode.insertBefore(js, fjs); }(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));</script>

The above script is well formed and minified for bloggers to load the website fast. You need to change the red coloured App Id to your app ID. Paste the script after the </body> tag and before the  </html> tag.


Update on New Facebook Modified Script 2.9 - No App ID

If you do not have an app ID, copy the following code.


<div id='fb-root'/>
<script>
/* <![CDATA[ */
    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
/* ]]> */
</script>

Check for Other XML Validation Errors

If you want to check for other XML validation errors, go to Online XML Syntax Error Parsing Validator Tool

Subscribe and Follow us if this works.



Whats Hot

About Author