Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 我们可以在VBA中通过css路径访问元素吗?_Html_Css_Excel_Vba - Fatal编程技术网

Html 我们可以在VBA中通过css路径访问元素吗?

Html 我们可以在VBA中通过css路径访问元素吗?,html,css,excel,vba,Html,Css,Excel,Vba,我正在通过vba自动化几个网站,并通过类名、标记名、id、名称或它们的组合来访问元素 我们是否可以通过css路径选择HTML文档中的元素 我在谷歌上搜索这个,但没有找到我的答案 xTremeExcel您可以使用jQuery完成此操作 这也是一篇关于CSS选择器的有用文章 如果您有这样的html: <html> <head> </head> <body> <h1 class="a">Heading a</h1>

我正在通过vba自动化几个网站,并通过类名、标记名、id、名称或它们的组合来访问元素

我们是否可以通过css路径选择HTML文档中的元素

我在谷歌上搜索这个,但没有找到我的答案


xTremeExcel

您可以使用jQuery完成此操作

这也是一篇关于CSS选择器的有用文章


如果您有这样的html:

<html>
<head>
</head>
<body>
    <h1 class="a">Heading a</h1>
    <h1 class="b">Heading b</h1>
</body>
</html>
以识别节点。“长度”仅用于演示目的。
您必须引用Microsoft XML 6.0才能使其生效

Dim xmlDoc As DOMDocument60
Set xmlDoc = New DOMDocument60
xmlDoc.Load ("c:\htmltest.htm")

Debug.Print xmlDoc.SelectNodes("//h1").Length
Debug.Print xmlDoc.SelectNodes("//h1[@class='a']").Length