Reputation: 31
I want to get text and data from a webpage. when a page load completes inside web-browser control, I just want to extract text from the page by element id? please help me how can i achieve this like html-agility & c#. Sorry for my poor english.
Upvotes: 0
Views: 555
Reputation: 1038710
You could use the GetElementbyId
method on the HtmlDocument
which allows you to retrieve some specific DOM element by its identifier:
string html = ... Read the HTML here
var htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.OptionFixNestedTags = true;
htmlDoc.LoadHtml(html);
var element = htmlDoc.GetElementbyId("someId");
if (element != null)
{
string data = element.InnerText;
}
Upvotes: 2