Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xpath node selection - how to select 2 different elements?

I am trying this as selecting multiple nodes via HtmlAgilityPack but it fails. So, what I am trying to do is collecting a nodes and li nodes inside the breadcrumbs div element.

This is what I tried:

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

What is the correct syntax?

like image 341
MonsterMMORPG Avatar asked Jan 04 '12 00:01

MonsterMMORPG


1 Answers

Solution is

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

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

like image 66
MonsterMMORPG Avatar answered Nov 09 '22 05:11

MonsterMMORPG