How to parse HTML from JavaScript in Firefox?

前端 未结 5 1916
无人及你
无人及你 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 13:40

    If your data is XHTML, so it's valid XML, then DOMParser (Mozilla) or loadXML (IE) may help. If not, I can't think of anything better than stripping the and and then passing it to a 's innerHtml.

    See 21.1.3 in Flanagan's Javascript guide (5th edition).

    Colin

提交回复
热议问题