iam using npapi frame work inside my Delphi project , iam able to read params with this current code
procedure TDemoPluginForm.btTestClick(Sender: TObject);
var
obj: IBrowserObject;
res: TStringList;
items, n: IBrowserObject;
i: integer;
begin
res:=TStringList.Create;
try
res.Add('Plugin element details:');
// Get object of plugin element
obj:=Plugin.GetPluginObject;
// Get element property
res.Add('id=' + string(obj['id']));
// Get child elements
res.Add('Child nodes:');
items:=obj.GetObject('childNodes');
for i:=0 to items['length'] - 1 do begin
n:=VarAsObject(items.Invoke('item', [i]));
if CompareText(n['tagName'], 'param') = 0 then
res.Add(Format('Tag: %s; Name: %s; Value: %s',
[string(n['tagName']),
string(n['name']),
string(n['value'])
]));
end;
MessageBox(Self.Handle, PChar(res.Text), PChar('Delphi Plugin'), MB_ICONINFORMATION);
finally
res.Free;
end;
end;
how could i read each param with its reference .
to be more specific if i have param like this
<param name = "delphi" value = "student" />
how could i read inside delphi if param = delphi then somestring := its value ?
You have the answer in your reach, you can use System.SysUtils.SameText
to achieve your goal:
procedure TDemoPluginForm.btTestClick(Sender: TObject);
var
obj: IBrowserObject;
res: TStringList;
items, n: IBrowserObject;
i: integer;
value : String;
begin
res:=TStringList.Create;
try
res.Add('Plugin element details:');
// Get object of plugin element
obj:=Plugin.GetPluginObject;
// Get element property
res.Add('id=' + string(obj['id']));
// Get child elements
res.Add('Child nodes:');
items:=obj.GetObject('childNodes');
for i:=0 to items['length'] - 1 do begin
n:=VarAsObject(items.Invoke('item', [i]));
if SameText(n['tagName'], 'param') then
begin
res.Add(Format('Tag: %s; Name: %s; Value: %s',
[string(n['tagName']),
string(n['name']),
string(n['value'])
]));
if SameText(n['name'], 'delphi') then
value := String(n['value']);
end;
end;
MessageBox(Self.Handle, PChar(res.Text), PChar('Delphi Plugin'), MB_ICONINFORMATION);
finally
res.Free;
end;
end;