I want to load an XML file and its CSS stylesheets into a textarea
ordiv
. Each XML file has CSS stylesheets that display it correctly:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="first.css"?>
<?xml-stylesheet href="second.css"?>
<book>
<sentence>
!!! SNIP !!!
If I load the file directly into a web browser by typing its URL into the address bar, it is displayed correctly, including all styling. Now I want to display it the same way, loading it dynamically.
I have tried several variations on this, e.g.
<textarea id="display">
</textarea>
$.ajax({
type: "GET",
url: "https://raw.githubusercontent.com/someplace/my.xml",
dataType: "text",
success: function(xml) {
alert("GET succeeded")
var xmlDoc = $.parseXML(xml);
document.getElementById("display").append(xmlDoc.childNodes);
}
});
I can't figure out how to dynamically apply styles to the parsed XML document and display it. I don't want to convert it to HTML, I just want to show the same documents that already display properly in the web browser.
Anyone know how to do this?