How to get the part of the html code from html code in c#? -


in program have used string variable content. have assigned small html program string. example,

string content = "<html> <head> <title>your title here</title></head> <body><h2>this medium header send me mail at<a href="mailto:support@yourcompany.com">support@yourcompany.com</a>.this new sentence without paragraph break.</h2></body></html>"; 

from want "this medium header send me mail @ support@yourcompany.com.this new sentence without paragraph break." alone.

this string available inside tag. how string using c#.

don't use string methods or regex parse html. can use htmlagilitypack.

string content = "<html> <head> <title>your title here</title></head> <body><h2>this medium header send me mail at<a href=\"mailto:support@yourcompany.com\">support@yourcompany.com</a>.this new sentence without paragraph break.</h2></body></html>";  var doc = new htmlagilitypack.htmldocument(); doc.loadhtml(content); string headertext = doc.documentnode.descendants("h2").first().innertext; 

result:

this medium header send me mail atsupport@yourcompany.com.this new sentence without paragraph break. 

Comments