I have the following HTML sample document:
.....
<div class="TableElement">
<table>
<tr>
<th class="boxToolTip" title="La quotazione di A2A è in rialzo o in ribasso?"> </th>
..
<th class="boxToolTip" class="ColumnLast" title="Trades più recenti su A2A">Ora <img title='' alt='' class='quotePageRTupgradeLink' href='#quotePageRTupgradeContainer' id='cautionImageEnt' src='/common/images/icons/caution_sign.gif'/></th>
</tr>
<tr class="odd">
..
<td align="center"><span id="quoteElementPiece6" class="PriceTextUp">1,619</span></td>
<td align="center"><span id="quoteElementPiece7" class="">1,6235</span></td>
<td align="center"><span id="quoteElementPiece8" class="">1,591</span></td>
<td align="center"><span id="quoteElementPiece9" class="">1,5995</span></td>
..
</tr>
</table>
</div>
......
I need to get the values corresponding at quoteElementPiece 6,7,8,9 and 17 (currently further in the document) section.
I am simply searching one by one in the code at the moment:
int index6 = doc.IndexOf("quoteElementPiece6");
..
int index17 = doc.IndexOf("quoteElementPiece17");
I want to improve this by scanning in one go and having all the indexes for the substrings I need. Example:
var searchstrings = new string[]
{
"quoteElementPiece6",
"quoteElementPiece7",
"quoteElementPiece8",
"quoteElementPiece9",
"quoteElementPiece17"
};
int[] indexes = getIndexes(document,searchstrings); //indexes should be sorted accordingly to the order in searchstrings
Is there anything native in .NET doing this (LinQ for istance)?
I know there are HTML Parser libraries but I prefer avoiding using those, I would like to learn how to do this for each kind of document.