Open scripting opened 3 years ago
The magic seems to be in https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/xml/DocumentXMLTreeViewer.js
Looking at the sibling source files, I think the browser engine runs the javascript against the source XML document to transform it into a styled HTML document. I did not find any glaring items in the javascript that would prevent it from being used in the situation you need. To be clear, this wouldn't be directly what you asked for, but it would be somewhere in between an existing browser API and redoing from scratch.
You can set the url to a data format such as
data:text/xml;,<xml><name>this is a test</name></xml>
You should be able to do this programatically as well as just entering it in the browser address bar
Perhaps an XSLT, but this assumes you know the possible elements allowed in the XML. Very under-utilized feature that most browsers still support.
When you view a normal XML file in the browser, Chrome gives you a simple, readable XML viewer. I want to be able to invoke that viewer from a JavaScript app running in the browser. Some kind of JavaScript call like
window.xmlViewer (xmltext);
The only other option is to rewrite it from scratch, which I'm open to doing but would rather not. Does anyone know if such a thing exists?