Click here to Skip to main content
15,900,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form and one webbrowser now I want to retrieve data displayed on the webbrowser must do?

HTML
<div id="divTop">

    <div id="chart" style="width: 500px; float: right;"></div>
    <div id="grid" style="margin-removed 505px; height: 700px;"></div>

</div>


I want to take content from div tag but do not know how
Posted

try with GetElementByID method of webBrowse document
C#
HtmlElement e1 = webBrowser1.Document.GetElementById("chart");
MessageBox.Show(e1.InnerText);
 
Share this answer
 
Comments
DamithSL 19-Jun-15 2:49am    
this is unrelated error to your original question, if you able to retrieve content of div tag using above answer, please mark it as answer to your question. Ask different question for new questions you are facing.
Member 11530690 19-Jun-15 3:02am    
Thanks, but I do not get content in div tags, I use a foreach loop to find the result, but the result is reported error
DamithSL 19-Jun-15 3:06am    
question ask about div tag, not div tags.
if you need div tags you better use GetElementsByTagName method
this documentation[^]
Member 11530690 19-Jun-15 3:29am    
I tried but it error cannot implicitly convert type 'system.windows.forms.htmlelement' to ' system.windows.forms.htmlElementCollection'
HtmlElement texts = webBrowser1.Document.GetElementById("text-conent");
           string kq = "";
           foreach (var item in texts)
               {
                   kq += item.InnerText + Environment.NewLine;
               }
           richTextBox1.Text = kq;

Program error [ foreach statement cannot operetta on variables of type "system.windows.forms.htmlelement" because "system.windows.forms.htmlelement" does not contain a public definition for GetEnumenrator
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900