The Computer Oracle

Displaying XML in the Chrome browser

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Sunrise at the Stream

--

Chapters
00:00 Question
00:54 Accepted answer (Score 20)
02:01 Answer 2 (Score 30)
02:17 Answer 3 (Score 6)
02:51 Answer 4 (Score 6)
03:21 Thank you

--

Full question
https://superuser.com/questions/972/disp...

Question links:
[Google Chrome Extension Beta Site]: https://chrome.google.com/extensions/det...

Accepted answer links:
[Greasemetal]: http://greasemetal.31tools.com/
[XML Tree]: http://userjs.org/scripts/general/develo...
[the source]: http://userjs.org/scripts/download/gener...
[the screenshot]: http://www.howtocreate.co.uk/operaStuff/...
[the example XML]: http://www.howtocreate.co.uk/operaStuff/...
[jsgui.com/xml-viewer]: http://jsgui.com/xml-viewer
[How to print pretty xml in javascript?]: https://stackoverflow.com/questions/1187...
[Pretty XML Tree]: http://blog.webkitchen.cz/pretty-xml-tre...

Answer 2 links:
[here for the extension]: https://chrome.google.com/extensions/det...

Answer 3 links:
[Web Inspector]: http://webkit.org/blog/197/web-inspector.../

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#googlechrome #display #xml

#avk47



ANSWER 1

Score 30


I have now created a simple extension to add this functionality.

UPDATE see here for the extension.




ACCEPTED ANSWER

Score 20


I guess your best bet is to use a bookmarklet or install Greasemetal (which is Firefox' Greasemonkey for Chrome), combined with a script like XML Tree (old, but the source may still help). A more generic syntax highlighting script may help as well, but I doubt if you'll easily find one with code folding.

Note that whitespace might matter in XML. Not all XML viewers respect that; the screenshot created by the abovementioned XML Tree for the example XML does not respect it for the line Sample XML element containing a lot of text, enough to be put on a separate line.

(Unfortunately jsgui.com/xml-viewer is not responding while I am writing this.)

EDIT: How to print pretty xml in javascript? on Stack Overflow mentioned a newer version of XML Tree: Pretty XML Tree, using XSLT and claims to be faster. The demo does not respond to clicking in my Safari or Firefox, but may be helpful anyway.




ANSWER 3

Score 6


As far as I understand it the limitation is actually in the webkit rendering engine rather than in Chrome itself. I doubt we'll decent XML rendering in Chrome before they properly launch extensions, at which time someone will be able to code a community extension to handle text/xml files.

If you want an alternative to IE, the Firefox rendering of XML is pretty good.




ANSWER 4

Score 6


If you right-click on a node, and click "Inspect Element", you should get the WebKit Web Inspector, which has lots of fancy features including what you need; this should work for XML in addition to just HTML. Here's a screenshot from Safari, which has the same inspector:

Web Inspector