I am trying to migrate from an old code using twebrowser to the new tedgebrowser, but the edgebrowser doesn't have the same properties, so I can't use my old function anymore
I was using the function that I got here: GetElementByClass?
function GetInnersByClass(const Doc: IDispatch; const classname: string;var Lst:TStringList):Integer;
var
Document: IHTMLDocument2; // IHTMLDocument2 interface of Doc
Body: IHTMLElement2; // document body element
Tags: IHTMLElementCollection; // all tags in document body
Tag: IHTMLElement; // a tag in document body
I: Integer; // loops thru tags in document body
begin
Lst.Clear;
Result := 0 ;
// Check for valid document: require IHTMLDocument2 interface to it
if not Supports(Doc, IHTMLDocument2, Document) then
raise Exception.Create('Invalid HTML document');
// Check for valid body element: require IHTMLElement2 interface to it
if not Supports(Document.body, IHTMLElement2, Body) then
raise Exception.Create('Can''t find <body> element');
// Get all tags in body element ('*' => any tag name)
Tags := Body.getElementsByTagName('*');
// Scan through all tags in body
for I := 0 to Pred(Tags.length) do
begin
// Get reference to a tag
Tag := Tags.item(I, EmptyParam) as IHTMLElement;
// Check tag's id and return it if id matches
if AnsiSameText(Tag.className, classname) then
begin
Lst.Add(Tag.innerHTML);
Inc(Result);
end;
end;
end;
Then, for example, I call it using: GetInnersByClass(WebBrowser1.Document,'class name',lst);
And I get the innertext from the 'class name' into the variable lst
But TEdgeBrowser doesn't have the Document property.
It doesn't have to be the same function. What I need is to get the innertext from an Elemment loaded in the TEdgeBrowser.
Does anyone have any ideia how to do this?
Thank You