Re: How to iterate DOM
Posted: Fri Jun 16, 2017 7:33 pm
Hi,
You can do that in 2 ways and both of them can be found in the MiniBrowser demo :
https://www.briskbard.com/index.php?lang=en&pageid=cef
and here :
http://magpcss.org/ceforum/apidocs3/
You can do that in 2 ways and both of them can be found in the MiniBrowser demo :
- Inject some javascript code to iterate the DOM and register an extension to receive the results from the javascript code. This is explained here :
viewtopic.php?f=8&t=77 - Use a custom process handler ( TCefCustomRenderProcessHandler ) and iterate the DOM inside the DOMVisitor_OnDocAvailable function.
Take a look at the DPR file to see how to create TCefCustomRenderProcessHandler and don't forget to add the DOMVisitor_OnDocAvailable and ProcessHandler_OnCustomMessage functions to your application.
Then take a look at the TMiniBrowserFrm.VisitDOMMsg function in the uMiniBrowser.pas file. That function sends a message to the renderer process using a TCefProcessMessageRef that will be handled by the custom process handler to create a TCefFastDomVisitor which will allow you to iterate the DOM in DOMVisitor_OnDocAvailable.
In short : Call TMiniBrowserFrm.VisitDOMMsg and you'll be able to iterate the DOM inside the DOMVisitor_OnDocAvailable function.
https://www.briskbard.com/index.php?lang=en&pageid=cef
and here :
http://magpcss.org/ceforum/apidocs3/