私はこのようなhtml式を持っています:
"This is <h4>Some</h4> Text" + Environment.NewLine +
"This is some more <h5>text</h5>
そして、私はテキストを抽出したいだけです。したがって、結果は次のようになります。
"This is Some Text" + Environment.NewLine +
"This is some more text"
どうすればよいですか?
HtmlAgilityPackを使用する
string html = @"This is <h4>Some</h4> Text" + Environment.NewLine +
"This is some more <h5>text</h5>";
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var str = doc.DocumentNode.InnerText;
正規表現を使用して簡単:Regex.Replace(source, "<.*?>", string.Empty);