-1

I have an html table I need to query, get the contents and then act on that. this the table

   <table>
        <thead>
            <tr>
                <th>Version</th>
                <th>Usage</th>
            </tr>
        </thead>
        <tbody>

                <tr>
                    <td>1.0.1.1</td>
                    <td>86</td>
                </tr>


                <tr>
                    <td>1.0.0.1</td>
                    <td>65</td>
                </tr>


                <tr>
                    <td>1.0.1.0</td>
                    <td>28</td>
                </tr>


                <tr>
                    <td>1.0.0.0</td>
                    <td>1</td>
                </tr>

          </tbody>
    </table>

I'm getting that by passing the WebResponse through a regex expression.

What is the best way to get this into some data structure in C# so that I can query on the Version and Usage.. Baically have a List of class Foo.

Foo() { Version {get; set;} Usage {get; set;} }

Along those lines.

Thanks for your help

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Matt
  • 4,140
  • 9
  • 40
  • 64

1 Answers1

2

The best tool I've found for parsing HTML is the Html Agility Pack library. It is a fairly easy to use library, and will handle improperly formatted markup fairly well. You'll have to do the footwork of getting the data out from the library and into your own structures, but it'll make it easy for getting at the data.

MDV
  • 195
  • 1
  • 7