J'utilise HtmlAgilityPack pour analyser la page HTML. Je souhaite sélectionner une collection de balises h3, puis les parcourir en boucle. Pour chaque élément h3, je souhaite sélectionner un élément situé juste à côté. Voici mon échantillon 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>
Je sais comment sélectionner une collection de h3, mais je n'ai aucune idée de la manière de sélectionner ul à côté de chaque
Si le noeud actuel est h3
, utilisez cette XPath:
following-sibling::ul[1]
Il sélectionne 1 er ul
frère.