Project Description
MQuery is a new kind of manged code Library.
It gives you the well beloved jQuery syntax to simplify client side HTML document parsing, traversing and manipulating. All in managed code using Interop.SHDocVw and Microsoft.mshtml.

Currently the following parsing features are supported:
Query: Text, Attribute, Each, Lenght
Selectors: ID, Class, Element
Filters: Eq, First
Utilities: HasClass, Text, Attribute

Example:
Parsing this document:
<html>
<head></head>
<body>
    <table id="SelectTable">
        <tr>
            <td class="S">11</td><td>12</td><td class="S">13</td><td>14</td><td>15</td><td>16</td><td class="S">17</td><td>18</td><td>19</td>
        </tr>
    </table>
    <table id="DoNotSelectTable">
        <tr>
            <td>b11</td><td class="S">b12</td><td>b13</td><td>b14</td><td class="S">b15</td><td>b16</td><td>b17</td><td class="S">b18</td><td>b19</td>
        </tr>
    </table>
</body>
</html>
With this parser:
using mshtml;
using MQuery;
public void ParseDocument(mshtml.HTMLDocumentClass document)
{
    Query.Q("#SelectTable TR TD", document).Each((index, element) =>
        {
            if (element.HasClass("S"))
            {
                Console.WriteLine("{0}:{1}", index, element.Text());
            }
        }
    );
}
Give the following result:
0:11
2:13
6:17

Last edited Aug 7, 2009 at 9:23 AM by YehudaAdar, version 2