0

I've Been struggling with this for over 5 hours now

Example:

 <div id='xx'>content</div> 

How can i access Content of that div via GetHtmlElementById or any other solution based on "Id"

i tried

GeckoElement el = browser.Document.GetElementById("xx");
MessageBox.Show(el.TextContent); 

and im getting NullRefferenceException (Object reference not set to an instance of an object.)

Other example :Navigating to google.co.uk

browser.DocumentCompleted += delegate { 
                MessageBox.Show(browser.DomDocument.GetElementById("gbqfsa").TextContent);

            };

MessageBox should show me "Google Search" but no luck

System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=gecko fx StackTrace: at gecko_fx.Form1.b__2(Object , EventArgs ) in C:\Users\drs\AppData\Local\Temporary Projects\gecko fx\Form1.cs:line 44 at Gecko.GeckoWebBrowser.OnDocumentCompleted(EventArgs e) in C:\Users\hindlet\Documents\Visual Studio 2010\Projects\geckofx-15.0\Geckofx-Winforms\GeckoWebBrowser.Events.cs:line 177 at Gecko.GeckoWebBrowser.Gecko.nsIWebProgressListener.OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, UInt32 aStateFlags, Int32 aStatus) in C:\Users\hindlet\Documents\Visual Studio 2010\Projects\geckofx-15.0\Geckofx-Winforms\GeckoWebBrowser.cs:line 1700 InnerException:

hexdump
  • 143
  • 2
  • 8

1 Answers1

4
            GeckoHtmlElement ele;
            ele = geckoWebBrowser1.Document.GetHtmlElementById("myData");
            MessageBox.Show(ele.GetAttribute("Value"));

This works for me.

MikeNY
  • 41
  • 1
  • I was searching for this solution for few weeks - thanks a lot. But maybe You can tell me if this "Value" attribute is "InnerHtml" of ID div ? – Bri.H. Oct 18 '16 at 10:03