Knowledgebase Banner Advert

PageSpeed causes my page to display an XML Parsing Error message

This usually happens when using a content management or generation system (we've seen it with Munin and Magento for example). The full error message looks something like:

XML Parsing Error: mismatched tag. Expected: </li>.
Location: http://www.example.com/
Line Number 123, Column 4: </ul>

This happens when the generated content has a meta tag that identifies the content as XHTML but the content has markup that is not valid XHTML, and you have configured your webserver to set the content type to HTML, so the browser parses it as HTML and doesn't detect the invalid XHTML errors.

However, when convert_meta_tags is enabled (and it's a core filter so is on by default), PageSpeed inserts a content header into the response with the value in the meta tag, namely XHTML (application/xhtml+xml to be precise), resulting in the browser displaying the error message because it is now parsing the page as XHTML and it rejects the invalid content.

There are three solutions, in descending order of preference:

  • If the content is XHTML, write XHTML and validate it with an XHTML validator.
  • If the content is not XHTML, remove the meta tag that claims it is.
  • If the content is not XHTML but you can't remove the meta tag, say because your CMS doesn't let you, disable the convert_meta_tags filter in your pagespeed.conf:
  • Apache:

    ModPagespeedDisableFilters convert_meta_tags

    Nginx:

    pagespeed DisableFilters convert_meta_tags;




    Article adapted from PageSpeed ~ Frequently Asked Questions.

Share:

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

PageSpeed broke my site; what do I do?

First of all, sorry about that. The Pagespeed team put a lot of work into validating the...

I am getting 404s for rewritten resources when using Mod_Pagespeed

The most common reason that the rewritten resources 404 is because of mod_rewrite RewriteCond...

How to I enable Mod_PageSeed on my CPanel hosting account?

We have Google's PageSpeed module installed on every web hosting account but it is turned off by...