71

I love the Chrome browser, but I use XML quite a lot in my development work and when I view it in Chrome I just get the rendered text.

I know that the source view is slightly better, but I'd really like to see the layout and functionality that Internet Explorer adds to XML, namely:

  • Highlighting
  • Open/close nodes

Any ideas how I can get this on Chrome?


UPDATE:

The XMLTree Extension is available on Google Chrome Extension Beta Site.

8
  • 1
    Hmm... uh, firefox?
    – RCIX
    Jul 21, 2009 at 5:50
  • 37
    come on guys - use firefox answers aren't really helpful.
    – Josh
    Jul 21, 2009 at 9:34
  • 3
    Nice extension. Why don't you move your solution into its own answer, so you can accept it and it can be upvoted?
    – arathorn
    Jul 22, 2009 at 15:28
  • @arathorn - i have now added the plug-in as an answer - thanks.
    – Josh
    Jul 22, 2009 at 15:53
  • @Josh: Don't you want to change your accepted answer, also? (I assume that's possible.)
    – arathorn
    Jul 22, 2009 at 16:23

8 Answers 8

20
+100

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.

4
  • thanks - put me on the right track. got a working extension based on the xml tree script.
    – Josh
    Jul 22, 2009 at 10:19
  • @Josh, though I'm not using Chrome: thanks for the plug-in!
    – Arjan
    Jul 22, 2009 at 14:27
  • i've updated my extension to use xslt and a simular idea to pretty xml tree - but i hope working better :) - let me know what you think - same link as before.
    – Josh
    Aug 5, 2009 at 8:24
  • (I'm still not using Chrome, but given the earlier comments I read at chromeplugins.org/google/chrome-plugins/… I'm sure people are happy!)
    – Arjan
    Aug 5, 2009 at 19:44
30

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

UPDATE see here for the extension.

2
  • Can you make it work for download links to XML files? Chrome keeps asking me to save the file to disk :(
    – sorin
    Aug 9, 2013 at 11:00
  • 1
    Josh, that extension is now maintained by someone else?
    – Arjan
    Aug 15, 2013 at 12:07
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.

2
  • Either that, or they'll just create an extension equivalent to Firefox's "IE Tab," or perhaps "Firefox Tab" if you will. addons.mozilla.org/en-US/firefox/addon/1419
    – Tyler
    Jul 19, 2009 at 20:36
  • 1
    @MatrixFrog FF-tab for chrome, in which you can run IE-Tab for FF? ;D
    – pavsaund
    Jul 22, 2009 at 6:57
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

6
  • 2
    +1 this looks like the original poster's answer. I just checked and the "inspect element" option is there when viewing a raw XML file. It would be nice if this was the default rendering option for non HTML XML files; however two clicks isn't that much of a price to pay :) Jul 22, 2009 at 8:16
  • very cool - just a shame its not the default option for xml.
    – Josh
    Jul 22, 2009 at 8:30
  • Well, yeah. The problem is the browser has no way to know whether you want it to render the document or not, since XML is a perfectly valid medium for web pages (for example, homepage.mac.com/nathan_day/pages/news.xml). The Web Inspector is really just a developer tool (an awesome one!). By the way, Josh, did this count as the answer to the original question?
    – jtbandes
    Jul 22, 2009 at 8:43
  • It is a shame it's not the default renderer. Several times I have been forced to use IE for this purpose even though chrome is my browser of choice. Regarding, how will the browser know how to display the document? I don't care! Somehow IE and Firefox figure it out. Maybe something in the stylesheet, guesswork, magic...just do it!
    – Tundey
    Jul 22, 2009 at 14:30
  • @jtbandes - the script idea from @Arjan van Bentem was the best answer as it helped create the extension which i've also added as an answer.
    – Josh
    Jul 22, 2009 at 15:55
5

Chrome dev channel now features an XML viewer, which is invoked if the XML does not have an associated XSL (the same holds for the WebKit nightlies). Happy viewing!

1
2

I've tried many, but only XV — XML Viewer works for both regular XML and RSS feeds (if you turn it on in the settings).

1
  • That's great, that option was exactly what I was looking for.
    – huyz
    Aug 13, 2014 at 10:00
1

No need for fancy extensions(Which breaks if you load a 1MB sized XML file).

This post is old, but right now Chrome has fixed the bug and has added support for viewing XML directly in the browser. Just drag and drop any XML file and you can see the collapsible tree view of the file. It also supports viewing RSS feeds.

0

In my case (SharePoint 2013 REST API response ) XML Tree wins XV — XML Viewer

  • perfect Tag matching and highlighting on mouse over
  • unbeatable intuitive tree view format

Extra advanced features

  • XPATH query

    enter image description here

(in fact i installed XV first and it did nothing with my xml, but XML tree rocks it)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .