let’s say I have HTML stored in HTMLElement object. It’s outerHTML property looks like this.
<table>
<tr>
<td>
a
</td>
<td>
b
</td>
<td>
c
</td>
</tr>
</table>
How do I get the third <td> with the innerHTML "c"?
I have no problem in switching the data to some other object, I just want to be able to do this easily? I was thinking about parsing it as XML and then using XPath, but I had no luck with that…
Use HtmlAgilityPack to load the document and then you can apply an XPath on it in order to retrieve the node(s) you are interested in.
The expression in your case would be:
If you have more rows, then it will return all td elements with position 2 (zero based index) from each row.