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:
GeckoHtmlElement ele;
ele = geckoWebBrowser1.Document.GetHtmlElementById("myData");
MessageBox.Show(ele.GetAttribute("Value"));
This works for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.