0

Is there a mobile equivalent like SHDocvw.dll for exposing the HTML Document Object Model in Xamarin? Yes, I realize you can't use Internet Explorer on an android device, that's why I said 'like'.

I've already tried HTMLAgilityPack and have not had any success. The original C# code in windows forms is below and works great (obviously, this is not the complete code....). The WebView object in Xamarin appears to be very unusable for web scraping.

I do not want to use xaml and want to keep everything in code. Also, if there is a way to use a browser only in memory that is my optimal solution. I don't want to display a browser.

        HtmlElementCollection divs = webBrowserSF.Document.GetElementsByTagName("div");

        foreach (HtmlElement div in divs)
        {
            if (div.Name == "Collapsed")
            {
                blnCollapsed = true;
            }

            if ((div.Name == "cr_cashflow_strap") && (blnCollapsed == true))
            {
                div.InvokeMember("Click");
                blnCollapsed = false;
            }
        }

        HtmlDocument htmldoc = webBrowserSF.Document;
        HtmlElementCollection trs = webBrowserSF.Document.GetElementsByTagName("tr");
        intTR_Row = 0;       // start with first value in tr collection

        foreach (HtmlElement tr in trs)
        {
            HtmlElementCollection tds = tr.GetElementsByTagName("td");    //get all the td elements in that specific tr
            intCell = 0;    //'start with the first value in the td collection
            blnSkipRow = false;

            foreach (HtmlElement cl in tds)
            {
                // These are the default measures to display
                if (
                        (intTR_Row > 1) &&
                        (cl.InnerText != null) &&
                        (intCell == 0) &&
                        (
R Vincent
  • 1
  • 2
  • It has little to do with C# or Xamarin, as you are trying to access a native resource/control which Android SDK or related materials are more relevant. About how to extract HTML from `WebView` I can see tons of SO threads, while if you decide to use WebKit or Chromium, there might be more threads. BTW, recommending a library is off-topic. There are off screen solutions like CefSharp for desktop, but none for mobile, https://github.com/cefsharp/CefSharp – Lex Li Dec 04 '16 at 06:16
  • Hmmm. Isn't my question directly related to asking for a recommendation, so it's not really off topic, but directly on topic. BTW, I've looked at those "tons of SO threads" and not found anything really useful. – R Vincent Dec 04 '16 at 22:37

0 Answers0