How to parse HTML from JavaScript in Firefox?

前端 未结 5 1920
无人及你
无人及你 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:39

    You can use the DOMParser to parse HTML - even tag soup:

    var parser = new DOMParser()
    parser.parseFromString('hi

    helloworld

    ', 'text/html')

    I don't know if it handles partial table markup well, but it should create the same DOM the browser itself does for pretty much any markup.

提交回复
热议问题