In a Xamarin.Forms (UWP) project, I have a WebView control whose Source is created with an HTML string, like this:
var webview = new Xamarin.Forms.WebView
{
Source = new HtmlWebViewSource
{
Html = "<html>....</html>"
}
};
The HTML contains JavaScript that dynamically generates HTML inside the <body>. This renders perfectly on the screen. That means the WebView understands the DOM that is being created with the JavaScript. Great.
But now I need to parse through some of the generated HTML, but all I can seem to access is the original HTML string that I passed in as the Source, and not the final generated DOM.
Is there a way to convert the DOM generated by the JavaScript and understood by the WebView into a string so that I can parse (using a library like HTML Agility Pack or AngleSharp) and pull out some segments of the HTML? This can be in Xamarin.Forms or UWP (the platform I'm targeting).
NOTE: In full disclosure (in case it helps, and to avoid accusations of this being an XY problem), I am ultimately trying to solve the problem of printing a WebView with multiple pages on UWP - research on this has been met with very sparse information. I have a solution that works for HTML that is not dynamically generated with JavaScript - basically I'm pulling out parts of the HTML that represent printable pages, and I'm adding those as separate pages for print and print preview. But as mentioned earlier, I can't seem to parse through dynamically generated content.