lse;
if not FActive then exit;
//关于xpath语法说明,参见 www.w3.org/TR/xpath
xpath:=UsersTag+''[''+U_Id+''="''+userid+''"]'';
xuser:=FXMLDoc.documentElement.selectSingleNode(xpath);
if xuser<>nil then result:=true;
end;
initialization
{ Initialise COM }
CoInitialize(nil);
finalization
{ Tidy up }
CoUninitialize();
end.
调用上面单元的实例的代码,unit单元:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,XMLOptionUnit, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Button3: TButton;
Button4: TButton;
Button5: TButton;
WebBrowser1: TWebBrowser;
Label1: TLabel;
Button6: TButton;
Button7: TButton;
Button8: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
private
{ Private declarations }
FXMLOption:TXMLOption;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
FXMLOption:=TXMLOption.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FXMLOption.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FXMLOption.CreateBlank(edit1.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
auser:RecUser;
begin
auser.U_Id:=edit2.Text;
auser.U_Name:=''tom'';
auser.U_Sex:=''男'';
auser.U_Birth:=''1979-8-7'';
auser.U_Tel:=''1236547890'';
auser.U_Addr:=''tom 大街 8 号'';
auser.U_PostCode:=''100018'';
auser.U_Email:=''tom@888.com'';
FXMLOption.AppendUser(auser);
WebBrowser1.Navigate(ExtractFilePath(application.ExeName)+edit1.Text);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
FXMLOption.OpenXml(edit1.Text);
WebBrowser1.Navigate(ExtractFilePath(application.ExeName)+edit1.Text