Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.
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.
I just uploaded a new version of the MiniBroser demo with a simple DOM iteration.
Download CEF4Delphi again and check the SimpleDOMIteration function at the DPR file.
To test it compile MiniBrowser and run it. Wait for google to be completely loaded, right-click and select 'Visit DOM'. Close MiniBroser and open the debug.log file. You should see the names of several HTML elements at the end of that log.
You can declare the variable before the DOMVisitor_OnDocAvailable function.
Take a look at the declaration of TempProcessHandler in MiniBrowser.dpr (line 71)
Remember that DOMVisitor_OnDocAvailable is called from another process and you might need a mutex to protect the S variable if you want to use it from several processes at the same time.
Edit : After reading more carefully your code, you can declare it next to the "myFile" variable and pass it as a "var" parameter to "ProcessNode".