Take the 2-minute tour ×  What is the best way to parse (get a
DOM tree of) a HTML result of XmlHttpRequest in Firefox?   I do
not have the DOM tree, I want to acquire it.  XmlHttpRequest's
"responseXML" works only when the result is actual XML, so I
have only responseText to work with.  The innerHTML hack doesn't
seem to work with a complete HTML document (in <html></html>). -
turns out it works fine.  share|improve this question Browsers
parsing plain html code since they are exist. But that's so sad
that there is no simple, standard way that can invoke the
browser's parser to make a HTMLDocument object from a html
string... –  Calmarius Apr 25 '11 at 18:32  5 Answers 5  up vote
19 down vote accepted  innerHTML should work just fine, e.g.  //
This would be after the Ajax request: var myHTML =
XHR.responseText; var tempDiv = document.createElement('div');
tempDiv.innerHTML = myHTML.replace(/<script(.|\s)*?\/script>/g,
'');  // tempDiv now has a DOM structure:
tempDiv.getElementsByTagName('a'); // etc. etc. s