|
Rank: Member Groups: Member
Joined: 9/25/2014 Posts: 19
|
Hi, I need parse the html but, the value "body" is null. What is the problem ?
Code: C#
public Form1()
{
string htmlBasic = @"<html><head></head><body>teste</body></html>";
webView1.LoadHtml(htmlBasic); //OR webView1.LoadUrl("www.nytimes.com");
webView1.LoadCompleted += new EO.WebBrowser.NavigationTaskEventHandler(webView1_LoadCompleted);
}
void webView1_LoadCompleted(object sender, EO.WebBrowser.NavigationTaskEventArgs e)
{
EO.WebBrowser.DOM.Window domWindow = webControl1.WebView.GetDOMWindow();
EO.WebBrowser.DOM.Element body = domWindow.document.body;
}
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Thanks for posting in the forum. We have confirmed that this is a bug. Please use the following code instead:
Code: C#
//The return value is actually an JSObject object
object bodyObj = webControl1.WebView.EvalScript("document.body");
//Cast the JSObject into an Element
EO.WebBrowser.DOM.Element body = JSObject.CastTo<EO.WebBrowser.DOM.Element>(bodyObj);
You can find more details about EvalScript and JSObject here: http://www.essentialobjects.com/doc/6/advanced/js.aspxPlease feel free to let us know if you still have any questions. Thanks!
|
|
Rank: Member Groups: Member
Joined: 9/25/2014 Posts: 19
|
Hi, Thanks for the reply. Great with following code worked. Thanks! eo_support wrote:Hi, Thanks for posting in the forum. We have confirmed that this is a bug. Please use the following code instead:
Code: C#
//The return value is actually an JSObject object
object bodyObj = webControl1.WebView.EvalScript("document.body");
//Cast the JSObject into an Element
EO.WebBrowser.DOM.Element body = JSObject.CastTo<EO.WebBrowser.DOM.Element>(bodyObj);
You can find more details about EvalScript and JSObject here: http://www.essentialobjects.com/doc/6/advanced/js.aspxPlease feel free to let us know if you still have any questions. Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
You are very welcome. Thanks for confirming that it works for you!
|
|