Making XML human-readable without XSLT

7 dfabulich 2 9/2/2025, 7:58:14 PM jakearchibald.com ↗

Comments (2)

dfabulich · 19h ago
This article proposes two options, one where you add a `<script>` tag in the XML body, which breaks validating parsers, and another approach where you attach CSS to the XML document with `<?xml-stylesheet type="text/css" href="styles.css"?>`, but this only works with `Content-Type: text/xml` and not `application/rss+xml` or `/atom+xml`.

It would be great if browsers were to support a header (or some other out-of-band signal) would allow me to attach some CSS + JS to my XML without any other changes to the XML content, and without changing the Content-Type header.

Specifically, I'd love to be able to keep my existing application/rss+xml or application/atom+xml Content-Type header and serve up a feed that satisfies a validating parser, but attaching CSS styling and/or JS content transformations.

jaffathecake · 7h ago
Browsers don't want to add new ways of running script. That said, I wonder if `<?xml-stylesheet type="text/javascript" href="script.js"?>` could work. It's kinda weird, but `xml-stylesheet` can already run script via XSLT, so it isn't a new way to run script.