1

I was wondering if there's such a library or if anyone could give me hints on how to implement something like this.

What I want exactly is the functionality of DOM Explorer (to be more specific, when you are on any browser and hit F12 window with DOM Explorer pops where you can look through various aspects of HTML and CSS). I want to know if it would be possible to create this function for WebView and if so, any example would be appreciated.

Note: I am working on Visual Studio 2015, WinRT(Windows Universal 8.1), C# project.

Thanks!

p_q
  • 31
  • 6
  • As far as I know, it is not possible to develop such tool for WebView inside a UWP APP. – Elvis Xia - MSFT Oct 04 '16 at 07:24
  • Does anyone then know of a way to extract all HTML tags from string? I would want to get all of them (
    , ,
    – p_q Oct 04 '16 at 08:50
  • Have you used FireBug! that already have it.. – MarmiK Oct 07 '16 at 11:24
  • MarmiK - No, you didn't get it I guess. I want to develop a similar structure, but for a different reason. – p_q Oct 09 '16 at 16:16

1 Answers1

2

The only way to explore DOM right now is to invoke a javascript function with WebView.InvokeScriptAsync() method. So, I suppose if in your WebView.DomContentLoaded event handler you do something like this:

var result = await this.webView.InvokeScriptAsync("eval", new[] { "document.documentElement.outerHTML;" });

you'll get full DOM in the result variable.

Andrei Ashikhmin
  • 2,401
  • 2
  • 20
  • 34
  • Well I can get exactly that (but I believe better since it seems a bit "fuller") with HtmlAgilityPack.HtmlDocument and writing it out with StringWriter. But what I was curious about is the functionality part it self as shown in this picture (https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/71/metablogapi/2816.datwsaawfdtii-image5_760x526.PNG). It has double window kind of view as well to explore deeper in CSS. Sorry for bad formating. – p_q Oct 04 '16 at 06:36
  • To be more clear - what I want to implement (or move towards implementing) is F12 developer tools, but only the DOM Explorer part. – p_q Oct 04 '16 at 06:54
  • Yes, I understand what you want to implement. But as I said, the only known way to interact with DOM in UWP apps is InvokeScriptAsync method. – Andrei Ashikhmin Oct 04 '16 at 07:21
  • I did a mistake and haven't noticed. I am actually working on WinRT (Windows Universal 8.1) project. Does that change anything or? – p_q Oct 07 '16 at 11:03
  • Nope. Same story. – Andrei Ashikhmin Oct 07 '16 at 11:21