[thelist] Display XML document inside an HTML document

James Hardy evolt at weeb.biz
Fri Jan 21 07:08:14 CST 2005


And lo; it came to pass that the great prophet, Joe Ngo spake. And the 
huddled masses rejoiced to hear:
> Is there a way to display XML document inside another HTML document? I
> want something that uses the browsers capability of displaying the XML
> tree. For example, if you open an XML document on IE or Mozilla, the
> document is displayed in a structured fashion such that you can
> collapse/expand each node.
> 
> ...
>

Why not use XSL to convert the XML into an (x)HTML document fragment you 
can put into a div.

Basicly that is all the browsers do - push the whole lot through XSL to 
produce an entire HTML document with javascript to enable the opening 
and closing of nodes.

Mozilla's XSL is publicly available at: 
http://lxr.mozilla.org/mozilla/source/content/xml/document/resources/XMLPrettyPrint.xsl

I believe IE's is available through a res: URL, however you would not 
legally be able to use it - the moz one is licenced under MPL so you 
might be able to legally modify it to use in your app.

James


More information about the thelist mailing list