c# - HtmlAgilityPack SelectNodes Syntax -


i have following html:

<tbody>     <tr>         <td class="metadata_name">headquarters</td>         <td class="metadata_content">princeton new jersey, united states</td>     </tr>     <tr>         <td class="metadata_name">industry</td>         <td class="metadata_content"><ul><li><a href="/q-engineering-software-jobs.html" rel="nofollow">engineering software</a></li><li><a href="/q-software-development-&amp;-design-jobs.html" rel="nofollow">software development &amp; design</a></li><li><a href="/q-software-jobs.html" rel="nofollow">software</a></li><li><a href="/q-custom-software-&amp;-technical-consulting-jobs.html" rel="nofollow">custom software &amp; technical consulting</a></li></ul></td>     </tr>     <tr>         <td class="metadata_name">revenue</td>         <td class="metadata_content">$17.5 million</td>     </tr>     <tr>         <td class="metadata_name">employees</td>         <td class="metadata_content">201 500</td>     </tr>     <tr>         <td class="metadata_name">links</td>         <td class="metadata_content"><ul><li><a href="/url?q=http%3a%2f%2fwww.site.com&amp;h=085df2ca" target="_blank">company website</a></li></ul></td>     </tr> </tbody> 

i want able load metadata_content value (ex "$17.5 million") in var metadata_name = value (ex: "revenue").

i have tried use combinations of code few hours...

orghtml.documentnode.selectnodes("//td[@class='metadata_name']")[0].innerhtml; 

but i'm not getting right combination down. if have helpful selectnodes syntax - me solution appreciate it.

it seems you're looking this:

var found = orghtml.documentnode.selectsinglenode(     "//tr[td[@class = 'metadata_name'] = 'revenue']/td[@class = 'metadata_content']"); if (found != null) {     string html = found.innerhtml;     // use html } 

note text of element, should use found.innertext, not found.innerhtml, unless need html content.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -