Adding OR clause in Node selection criteria - HTMLAgility
-
30-09-2019 - |
Question
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
Solution
Xpath does have an OR operator. Try this for your selection query -
"//td[@class=\"roomPrice figure\" or @class=\"roomPrice figure bb\"]"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow