本文介绍了在VBScript中使用MSHTML解析html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在VBScript中使用MSHTML将字符串加载为html文件并进行解析.我可以使用"InternetExplorer.application"来执行此操作,但我想使用"htmlfile"(MSHTML.HTMLDocument)来执行此操作

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)

以下代码:

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

给出此错误:

如何加载html字符串?

How do I load the html string?

推荐答案

可能是作弊,但似乎可行:

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

这篇关于在VBScript中使用MSHTML解析html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 00:05