Reputation: 13
How do I read data in-between html tag such as <strong>
. For example.
<strong id="food">40</strong>
How do I retrieve the integer 40 from there ? I tried
myBrowser.Document.GetElementById("food").GetAttribute("value");
Upvotes: 1
Views: 2914
Reputation: 599
InnerText
[STAThread]
static void Main(string[] args)
{
WebBrowser w = new WebBrowser();
w.Navigate(String.Empty);
HtmlDocument doc = w.Document;
doc.Write("<html><head></head><body><p id=\"food\">40</p></body></html>");
Console.WriteLine(doc.GetElementById("food").InnerText);
Console.ReadKey();
}
Upvotes: 1