Question

I have next part of html code:

<div class="resum_card">
  <p><a href="#opyt" class="no_decore">Experience:</a> 5 years</p>
</div>

And what i try inside the code:

nodeValue = hd.DocumentNode.SelectSingleNode("//div[@class='resum_card']//p//a[@class='no_decore']//following-sibling::a");

But it return me null, can anybody help me?

Was it helpful?

Solution

You can try this XPath to get text node after <a> element :

nodeValue = hd.DocumentNode
              .SelectSingleNode("//div[@class='resum_card']/p/a/following-sibling::text()");

Note: simply use single slash (/) instead of double (//) to select element that is direct child of current element. It is better performance wise.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top