How can I get the value from the p tag ( France in this example) using the HtmlAgilityPack from the next fragment?

 <p class="pclass"> France<br /> <span class="sclass1">COOK & SHARE</span><br /> <span class="sclass2">Hall</span> </p> 

tried so

 var node = htmlDoc.DocumentNode.SelectSingleNode("//p[@class='pclass']"); var country = node.InnerText; 

but I get a shared innerText.

  • node.InnerHtml; ? - tym32167
  • @ tym32167, no. dotnetfiddle.net/H3J6vt - Aleksandr H.
  • one
    var node = htmlDoc.DocumentNode.SelectSingleNode("p[@class='pclass']").FirstChild.InnerText.Trim(); ? - tym32167
  • You can use the following xpath: //p[@class='pclass']/text() . - Alexander Petrov

0