C#HTML敏捷包通过类名称获取元素 [英] C# html agility pack get elements by class name

查看:73
本文介绍了C#HTML敏捷包通过类名称获取元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取其类包含某个单词的所有div:

I'm trying to get all the divs that their class contains a certain word:

<div class="hello mike">content1</div>
<div class="hello jeff>content2</div>
<div class="john">content3</div>

我需要获取其类包含单词"hello"的所有div. 像这样:

I need to get all the divs that their class contains the word "hello". Something like this:

resultContent.DocumentNode.SelectNodes("//div[@class='hello']"))

我如何使用敏捷包?

推荐答案

我明白了:

resultContent.DocumentNode.SelectNodes("//div[contains(@class, 'hello')]"))

这篇关于C#HTML敏捷包通过类名称获取元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆