How to get the entire document HTML as a string?

前端 未结 15 1979
暖寄归人
暖寄归人 2020-11-22 17:00

Is there a way in JS to get the entire HTML within the html tags, as a string?

document.documentElement.??
15条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 17:38

    You have to iterate through the document childNodes and getting the outerHTML content.

    in VBA it looks like this

    For Each e In document.ChildNodes
        Put ff, , e.outerHTML & vbCrLf
    Next e
    

    using this, allows you to get all elements of the web page including < !DOCTYPE > node if it exists

提交回复
热议问题