-1

I have data like this:

<tr class=hdr>
    <th class="al cf">Name</th>
    <th class="al">Type</th>
    <th class="ar">Used Drive Space</th>
    <th class="ar cl">Drive Size</th>
</tr>
<tr class="first o">
    <td class="al cf">ITPHOFPWRFL01B E:\ Label:LotusDomino </td>
    <td class="al">drive space</td>
    <td class="ar">489.39106GB</td>
    <td class="ar cl">549.9971GB</td>
</tr>

That file in HTML file and I want read that file like this (like read HTML file in notepad) and after that I want to start read from that first o and the data I want get is ITPHOFPWRFL01B E:\ || 489.9106GB || 549.9971GB ... How can I get the data?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Asked and answered many times. Here for instance: http://stackoverflow.com/q/2038104/215552, also here: http://stackoverflow.com/q/6063203/215552, and here too: http://stackoverflow.com/q/18065526/215552... – Heretic Monkey Apr 20 '17 at 20:53

1 Answers1

0

You should be using an html parser like htmlagilitypack.

You can use below code to retrieve it using HtmlAgilityPack

using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
    openFileDialog.Filter = "HTML files|*.html;*.htm";
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
        doc.Load(openFileDialog.FileName);
        foreach (var node in doc.DocumentNode.SelectNodes("//*[@class='first o']"))
        {
            foreach(var node2 in node.SelectNodes(".//td"))
            {
                txtContent.Text += node2.InnerHtml + " || ";
            }
        }
    }
}
Oliver
  • 43
  • 1
  • 7