'Apply a style to an external XML file

I know we can edit an XML file to include a reference to a stylesheet.

We want to display an external XML file (from a 3rd party job site's feed for a specific company) inside a WordPress webpage and style it somehow.

i.e. we can't insert a link to the stylesheet inside the XML file.



Solution 1:[1]

HTML has a link element to link to external style sheets, but not every XML-based format will have such an element. If there is no suitable element, you can still attach external style sheets by means of the xml-stylesheet processing instruction like this:

<?xml-stylesheet href="my-style.css"?>
... rest of document here...

This processing instruction (PI) must come before the first tag of the document. The type="text/css" is not required, but it helps the browser: if it doesn't support CSS, it knows it won't have to download this file.

Just as with the link element of HTML, there can be multiple xml-stylesheet PIs and they can have attributes to set the type, medium and title.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Areg Nikoghosyan