I am using Microsoft Webview2 to load a web page and below code is used to read the HTML content
string html = await webView1.ExecuteScriptAsync("document.documentElement.outerHTML");
The resulting output html appears with all tag opening, closing and other special characters encoded like below
\u003Chtml lang=\"en\" data-mode=\"light\">\u003Chead>\n \u003Cmeta charset=\"utf-8\">\n \u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\u003Ctitle data-argonaut-actions=\"true
Why does this happen? How do I get plain HTML?
var html = await webView2.ExecuteScriptAsync("document.documentElement.outerHTML");
html = Regex.Unescape(html);
html = html.Remove(0, 1);
html = html.Remove(html.Length - 1, 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With