在节点选择标准中添加 OR 子句 - HTMLAgility

发布于 2024-09-07 09:32:13 字数 429 浏览 2 评论 0原文

我可以使用 HTMLAgility 在节点选择中放置 OR 子句吗?

(HtmlAgilityPack.HtmlNodeCollection)doc.DocumentNode.SelectNodes("//td[@class=\"roomPrice figure\"]");

我需要的是有时它应该像 SelectNodes("//td[@class=\"roomPricefigure\"]"); 有时它就像 SelectNodes("//td[@class=\"roomPricefigure bb\"]");

我需要同时获取两个类 roomPrice图roomPrice 图bb

我怎样才能完成这个。

感谢您的帮助

Can I put OR clause in node selection using HTMLAgility

(HtmlAgilityPack.HtmlNodeCollection)doc.DocumentNode.SelectNodes("//td[@class=\"roomPrice figure\"]");

What I need is some times it should be like SelectNodes("//td[@class=\"roomPrice figure\"]");
and some times it is like SelectNodes("//td[@class=\"roomPrice figure bb\"]");

I need to get both either class will roomPrice figure OR roomPrice figure bb

How can I accomplish this.

Thanks for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往事随风而去 2024-09-14 09:32:13

Xpath 确实有一个 OR 运算符。尝试使用此方法进行选择查询 -

"//td[@class=\"roomPrice figure\" or @class=\"roomPrice figure bb\"]"

Xpath does have an OR operator. Try this for your selection query -

"//td[@class=\"roomPrice figure\" or @class=\"roomPrice figure bb\"]"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文