我试图提取一个矢量,该矢量包含所有图像的标签,这些图像包含在一个带有类“about-product-description”的html文档中的div中。图像可以位于div内的任何位置。
<html>
<body>
<div>
<div class="about-desc about-product-description xs-margin-top">
<div>
<img label="lbl003" alt="alternative" class="" width="70" height="70" src="https://...">
</div>
</div>
</div>
</body>
</html>
我尝试使用以下XPath,但它没有产生任何结果:
//div[@class='about-product-description')]//img/@label
谢谢大家
如果div的格式为
<div class="about-product-description">...</div>
在您的示例中,“about-product-description”只是类之一。
因此,下面的XPath应该可以解决这个问题
//div[contains(@class, about-product-description')]//img/@label