Parse html file using MSHTML in VBScript

怎甘沉沦 提交于 2019-12-02 02:09:23

问题


I'd like to load a string as an html file using MSHTML in VBScript and parse it. I can do this with "InternetExplorer.application" but I'd like to do it with "htmlfile" (MSHTML.HTMLDocument)

The following code:

Set h =  CreateObject("htmlfile")
h.body.innerHTML = "html goes here"

gives this error:

Microsoft VBScript runtime error: Object required: 'body'

How do I load the html string?


回答1:


Probably cheating, but seems to work:

  Dim oHF : Set oHF = CreateObject("HTMLFILE")
  oHF.write "<html><body></body></html>"
  oHF.body.innerHTML = "<p>WhatEver</p>"
  WScript.Echo oHF.body.innerTEXT


来源:https://stackoverflow.com/questions/9931429/parse-html-file-using-mshtml-in-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!