Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I have the following xpath: /html/body/div/div/div/div[2]/div/div/div/div[3]/div/table/tbody/tr/td[2]/a

from:

XML
<table class="search-result" width="100%">
<tbody>
<tr>
<td class="result-num">
<td class="result-header" colspan="2">
<a class="srtitle" href="http://books.ioba.org/books/129444230.html">Reader's Digest Condensed Books, Volume 3, 1970</a>



and I need to get the inner html of that xpath, however my application is giving me a null exception (i guess it is finding that the path is wrong or something)

here is my current code:

HtmlAgilityPack.HtmlNode rootNode = htmlDoc.DocumentNode;
titleBook = rootNode.SelectSingleNode(@".//table/tbody/tr/td[2]/a").InnerHtml.ToString();


I tried using @"//table[contains(@class, 'result-header')]/a" instead but still did not work.
what am I doing wrong?

thanks!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900