How To Get A Part Of Html In C#
please consider this scenario: we have two web page. a simple page that contains some controls and another page that Execute first page and get output HTML. for example: StringWrit
Solution 1:
Give the HTMLAgilityPack a try.
It's a lovely HTML parser that is commonly recommended for this. It will take malformed HTML and massage it into XHTML and then a traversable DOM, like the XML classes. So, is very useful for the code you find in the wild.
Solution 2:
Following are the options
- Apply regular expression to extract this text from response HTML
- Make XML document, Iterate through all the dive tags.
Solution 3:
HtmlElementCollection tData = wb.Document.GetElementsByTagName("div");
foreach (HtmlElement td in tData)
{
string name = "";
if (td.GetAttribute("classname") == "blink")
{
name = td.InnerText;
}
}
Solution 4:
we have had the same scenario in one of our project. I would suggest both Regex
and HTMLAgilityPack
Using the Agilitypack you can filter out the particular content from the web page with C# code and you also have
LINQ
thereThen if you need to fetch any particluar text within the Div or any individual value there you can make you of Regex.
Hope this helps
Post a Comment for "How To Get A Part Of Html In C#"