How to parse HTML from JavaScript in Firefox?

前端 未结 5 1911
无人及你
无人及你 2020-12-01 13:05

What is the best way to parse (get a DOM tree of) a HTML result of XmlHttpRequest in Firefox?

EDIT:

I do not have the DOM tree, I want to acquire i

5条回答
  •  离开以前
    2020-12-01 13:43

    At least for newer Firefox versions, an easier way is or will soon be available.

    https://developer.mozilla.org/en/HTML_in_XMLHttpRequest indicates that starting from FF11 it will be possible to ask for a DOM directly from the XHR by setting the responseType attribute to "document". At that point, the HTML will be parsed and the DOM stuck into responseXML as for an XML document.

提交回复
热议问题