Xpath node selection - how to select 2 different elements - htmlagilitypack

c# html-agility-pack nodes select xpath

Question

I am trying this as selecting multiple nodes via htmlagilitypack but it fails. What is the correct syntax ? So what i am trying is collecting a nodes and li nodes inside the breadcrumbs div element. Thank you.

 string srxPathOfCategory = "//div[@class='breadcrumbs']//li or //div[@class='breadcrumbs']//a";
 var selectedNodes = myDoc.DocumentNode.SelectNodes(srxPathOfCategory);

xpath, c#, htmlagilitypack

Solution

string srxPathOfCategory = "//div[@class='breadcrumbs']//li[@class='product'] | //div[@class='breadcrumbs']//a";

Accepted Answer

Solution is

string srxPathOfCategory = "//div[@class='breadcrumbs']//li[@class='product'] | //div[@class='breadcrumbs']//a";

So for " or " you need to use " | "



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why