How to display XML in a HTML page as a collapsible and expandable tree using Javascript?

Juha Syrjälä picture Juha Syrjälä · Sep 2, 2009 · Viewed 73.7k times · Source

How to display a XML document in a HTML page as a collapsible and expandable tree?

I'd like to display a XML document inside a HTML page as a nicely pretty printed tree structure. I'd like to be able to expand and collapse tree branches. For example Firefox browser does this when you load a plain XML file. I am looking how to do this in client-side with JavaScript.

Answer

Tarik picture Tarik · Sep 2, 2009

Creating An XML Viewer With JScript - Exsead XML Power Scripting

Display XML Files with Javascript

Update:

There seems to be a better and easier-to-use alternative than what I listed above many years ago:

https://www.jstree.com/

Hope they help.