3

I'm generally pretty happy with the native XML Viewer in Firefox.

It displays valid XML files (like the one below) clearly and helpfully.

Example of XML:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

  <url>
    <loc>https://example.com/</loc>
    <lastmod>2020-03-17T15:57:23+00:00</lastmod>
  </url>

</urlset>

However, I've noticed that as soon as I add XHTML to the XML (using the correct XHTML Namespace - see below), the XML Viewers in both Firefox and Chrome revert to displaying the XML as plaintext:

XHTML Namespace and Element:

  • XHTML Namespace: xmlns:xhtml="http://www.w3.org/1999/xhtml"
  • XHTML Element: <xhtml:link />

Example of XML + XHTML:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xhtml="http://www.w3.org/1999/xhtml">

  <url>
    <loc>https://example.com/</loc>
    <lastmod>2020-03-17T15:57:23+00:00</lastmod>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
    <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/" />
  </url>

  <url>
    <loc>https://example.com/de/</loc>
    <lastmod>2020-03-12T19:42:12+00:00</lastmod>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
    <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/" />
  </url>

</urlset>

For the longest time I thought I was introducing an error into my XML and invalidating it. But I have checked on numerous third-party XML validators and the XML is definitely valid. It's just that the browser-native viewers (apparently) can't cope with XHTML being included within the XML.

Is there anything I can do in this situation to help the native XML Viewers in Firefox and Chrome understand and parse the markup as XML or is there nothing to be done for now and 3rd-party software is the only answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.