XPath for elements with content inside?

c# html html-agility-pack xml xpath

Question

I useHtmlAgilityPack and I am in the following circumstance:

<table class='table-main odds '>   
   <tbody>
      <tr>..</tr>
      <tr>..</tr>
      <tr>..</tr>
      <tr></tr>
      <tr></tr>
  </tbody>
</table>          

three are all that are visible.tr contain material within, but I want the final product to simply make the top three accessible.tr . My code really returns all thetr :

 HtmlNode oddsTable = doc.DocumentNode
          .SelectSingleNode("//table[starts-with(@class, 'table-main')]");
 HtmlNodeCollection rows = oddsTable.SelectNodes("tbody//tr");

How can I use it to my advantage?xpath ?

I appreciate any guidance and explanation.

1
1
7/23/2018 8:47:24 PM

Accepted Answer

Depending on your definition of "content,"

  • any material: //tr[node()]
  • Feature content: //tr[*]
  • text message: //tr[text()]
  • Whitespace-free content: //tr[normalize-space()]
5
7/23/2018 7:29:19 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow