1

I'm using HtmlAgilityPack to parsing html page. I want to select a collection of tag h3 then loop through it, and for each h3 element, i want to select a element right next to it. Here is my sample Html:

<h3>Somthing here</h3>
<ul>list of something</ul>

<h3>Somthing here</h3>
<ul>list of something</ul>

<h3>Somthing here</h3>
<ul>list of something</ul>

<h3>Somthing here</h3>
<ul>list of something</ul>

<h3>Somthing here</h3>
<ul>list of something</ul>

I know how to select collection of h3, but i don't have any ideas how to select ul next to each

Doan Cuong
  • 2,594
  • 4
  • 22
  • 39

1 Answers1

2

If current node is h3, use this XPath:

following-sibling::ul[1]

It selects 1st ul sibling.

Kirill Polishchuk
  • 54,804
  • 11
  • 122
  • 125