How can I turn a string of HTML into a DOM object in a Firefox extension?,
I’m downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object?
It appears that the general solution is to create a hidden iframe and throw the contents of the string into that. There has been of updating to support text/html but as of Firefox 3.0.1 you still get an
NS_ERROR_NOT_IMPLEMENTED if you try.
Is there any option besides using the hidden iframe trick? And if not, what is the best way to do the iframe trick so that your code works outside the context of any currently open tabs (so that closing tabs won’t screw up the code, etc)?
is an example of why I’m looking for a solution other than the iframe hack, if I have to write all that code to have a robust solution, then I’d rather keep looking for something else.
Ajaxian actually had a today. You can probably use the js snippet they have posted there.
As for handling closing of a browser / tab, you can attach to the onbeforeunload event and do whatever you need to do.
That’s the answer How can I turn a string of HTML into a DOM object in a Firefox extension?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.
The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you