怎么解析HTML文件

如何解析HTML文件?
比如有个table,如何能根据ID找到它,然后读出有几个TR,每个TR中有几个TD,每个TD的内容,中间内容如果是类似这样的<font color="#999999">,那如何再解析有什么属性




  <table id="xxxx" width="100%">
  <tr> 
  <td bgcolor="#FFFFFF">登录用户:
  </td>
  </tr>
  <tr>
  <td bgcolor="#FFFFFF">用户类型:<font color="#999999">
  注册会员
  </font></td>
  </tr>
  </table>

------解决方案--------------------
Delphi(Pascal) code

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, StdCtrls, MSHtml;

type
  TForm1 = class(TForm)
    wb1: TWebBrowser;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
        wb1.Navigate('http://localhost:12880/mtm/abc.htm');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
        doc: IHTMLDocument2;
        mTable: IHTMLTable;
        mRow: IHTMLTableRow;
        mCell: IHTMLElement;
        mElement: IHTMLElementCollection;
        i,j: integer;
begin
        doc := wb1.Document as IHTMLDocument2;

        mTable := doc.all.item('xxxx',0) as IHTMLTable;
        for i:=0 to mTable.rows.length-1 do
        begin
                mRow := mTable.rows.item(i,0) as IHTMLTableRow;

                for j:=0 to mRow.cells.length-1 do
                begin
                        mCell := mRow.cells.item(j,0) as IHTMLElement;
                        showmessage(mCell.innerHTML);
                end;
        end;
end;

end.