some of the test.xml
<tr class="a"> <td align="left" nowrap="true">desc1</td> <td align="left">desc2</td> <td>desc3</td> <td align="left">desc4</td> <td align="left">desc5</td> <td>desc6</td> <td>desc7</td> <td>desc8</td> <td class="nr">desc9</td> </tr>
/create XpathNavigator to retrieve desc9 as the final value from the td.
> HtmlDocument document = new HtmlDocument(); document.Load(Server.MapPath("test.xml")); XPathNavigator xPathNavigator = document.CreateNavigator(); object o = xPathNavigator.Evaluate("/table/tbody/tr/td");
The debugger indicates that the value may be evaluated in the following way, which is highly laborious.
How do I get to desc9 the best?
Although I haven't utilized the XPathNavigator, this alternative uses the HTML Agility Pack and the SelectNodes/SelectSingleNode style.
string xPathSearch = "/table/tbody/tr"; HtmlNode tableRow = doc.DocumentNode.SelectSingleNode(xPathSearch); string description9 = tableRow.ChildNodes.InnerText;
string xPathSearch = "/table/tbody/tr/td"; HtmlNode tableColumn = doc.DocumentNode.SelectSingleNode(xPathSearch); string description9 = tableColumn.InnerText;
FYI - It seems that the examples provided with the Source are the greatest source of documentation for the HTML Agility pack. Why there isn't a separate download for it in the documentation is beyond me.
I believe your approach to this is flawed.
All you should have to do, in my opinion, is anything along these lines:
There isn't a copy of the documents online that I can link you to, but you can locate them at http://htmlagilitypack.codeplex.com/releases/view/44954 if you want further information.
Is there another reason you are using the HTML Agility Pack if all you are doing is reading XML, or is your test file the only one that is valid XML?