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

E

elsigh

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?
 
M

Martin Honnen

elsigh said:
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.
 
E

elsigh

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/

Right, but my issue is with being able to do this in IE (6). It's
neither slow nor difficult in Firefox.
 
E

elsigh

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top