Connecting Tech Pros Worldwide Help | Site Map

Convert an HTML DOM node to XML Document for XSLT in browser via javascript

elsigh
Guest
 
Posts: n/a
#1: Jul 22 '06
I'm wondering if anyone has any ideas about a way to quickly convert an
HTML DOM Node into an XML Document. The goal is that I want to perform
XSLT on the Node, which is coded correctly as XHTML. In Mozillae, it
works to parse the serializeToString output, but this functionality
doesn't exist for IE.

I've made one function that loops through all the nodes & attributes
and constructs a string that can be successfully parsed into xml, but
it is pretty slow. I can't imagine creating a XML Document object and
then doing the same loop to add on objects via XML DOM would be faster.

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.

Any ideas?

Martin Honnen
Guest
 
Posts: n/a
#2: Jul 22 '06

re: Convert an HTML DOM node to XML Document for XSLT in browser via javascript




elsigh wrote:
Quote:
I'm wondering if anyone has any ideas about a way to quickly convert an
HTML DOM Node into an XML Document. The goal is that I want to perform
XSLT on the Node, which is coded correctly as XHTML. In Mozillae, it
works to parse the serializeToString output,
Mozilla's XSLT processor and Opera 9's XSLT processor can do
transformation on HTML DOM nodes so I don't see why you would want to
make some transition to XHTML with JavaScript to then feed the node to
the XSLT processor. You can as well directly feed the node to the XSLT
processor.



--

Martin Honnen
http://JavaScript.FAQTs.com/
elsigh
Guest
 
Posts: n/a
#3: Jul 22 '06

re: Convert an HTML DOM node to XML Document for XSLT in browser via javascript


Mozilla's XSLT processor and Opera 9's XSLT processor can do
Quote:
transformation on HTML DOM nodes so I don't see why you would want to
make some transition to XHTML with JavaScript to then feed the node to
the XSLT processor. You can as well directly feed the node to the XSLT
processor.
>
Martin Honnen
http://JavaScript.FAQTs.com/
Right, but my issue is with being able to do this in IE (6). It's
neither slow nor difficult in Firefox.

petitevache
Guest
 
Posts: n/a
#4: Jul 22 '06

re: Convert an HTML DOM node to XML Document for XSLT in browser via javascript


Hi elsigh,

sorry for my english, I'm french...
congratulation for your reorganisable Datagrid, it's impressive.

perhaps, this can help you:
http://erik.eae.net/archives/2005/07/03/20.19.18/
and this :
http://www.pascarello.com/TestHTMLXMLfromserver.htm

elsigh
Guest
 
Posts: n/a
#5: Jul 23 '06

re: Convert an HTML DOM node to XML Document for XSLT in browser via javascript


Thanks petitevache!

Thing is - both of those examples involve using Ajax to solve the
problem - by getting something down from the server as XML. I'm
currently using parseFromString after creating a string in IE - looping
through the DOM an assembling the string piece by piece - which is
really slow, but seems to be the only way to get well formed xhtml from
the html DOM in IE. But if there was a faster way, or a way to get an
XML Document somehow more readily from an HTML DOM node, that would
really be perfect. Maybe there is just no way.
-l

petitevache wrote:
Quote:
Hi elsigh,
>
sorry for my english, I'm french...
congratulation for your reorganisable Datagrid, it's impressive.
>
perhaps, this can help you:
http://erik.eae.net/archives/2005/07/03/20.19.18/
and this :
http://www.pascarello.com/TestHTMLXMLfromserver.htm
Closed Thread