I would like to use javascript to serialize the current state of the DOM tree to a string. The resulting format doesn’t matter so much though I would prefer html.
Is there an easy way to do this?
For the record, I would like to automate downloading a page with PhantomJs, manipulating it with js scripts, and save the current state of the page (but not as an image or pdf).
You can serialize any element or part of dom using XMLSerializer .Here is the code