[xsl] Convert an HTML DOM node to XML Document for XSLT in browser (via Javascript)

Subject: [xsl] Convert an HTML DOM node to XML Document for XSLT in browser (via Javascript)
From: Lindsey Simon <lsimon@xxxxxxxxxxxx>
Date: Sun, 23 Jul 2006 13:24:57 -0500
Hi list,

I'm wondering if anyone has any novel ideas about a way to quickly convert an HTML DOM Node into an XML Document - mainly for IE. The goal is that I want to perform XSLT on the Node, which is coded correctly as XHTML. In the Mozillae, it works to parse the serializeToString output or just do XSLT on the node even (and both are really fast), but this functionality (serializeToString) doesn't exist for IE - I specifically need an XML Document on which to perform the xslt in the browser via Javascript.

I've made a function that loops through all the nodes & attributes
and constructs a string that can then be successfully parsed as a new XML doc, but it is obviously going to be slow and scale poorly. I don't imagine that creating a new blank XML Document object and then doing the same loop over the HTML DOM and then adding on objects onto a blank XML Document via XML DOM would be faster - it's the loop that is the problem.


I don't want to send the html up to a server (to be tidied or whatever) and it just seems like there might be some magick way to do this that I can't come up with. I'm beginning though to just accept that this is just a bummer in IE - doing XSLT on HTML nodes - and I may just have to live with my hack for that. I'm doing the xslt in Javascript using Sarissa, if that's helpful info.

Any ideas?
Thanks!

--

Lindsey Simon
lsimon@xxxxxxxxxxxx
Key fingerprint = C6A9 B9D9 677E A631 3E7F  43BF 5E2F 77F1 A33C B117
Public Key: http://www.commoner.com/pubkey.asc

Current Thread