I want to convert a Javascript DOM HTMLDcument to a string that I can write to a file. But how do you do the string conversion of the HTMLDocument to xml?!
Update If possible I'd like to see the html that is generated once any dynamic javascript rendering has been applied.
The DOM way of converting HTMLDocument object to XML is:
new XMLSerializer().serializeToString(oDocument);
In Internet Explorer there is no way to get proper XML representation of HTML document object by any built-in means. There you would need to implement serialization mechanism yourself - traversing the DOM tree and creating XML string.
'<html>'+document.documentElement.innerHTML+'</html>'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With