views:

57

answers:

1
<a> contents <strong>strong content</strong> </a>

I want a only the "contents" i.e present between <a> and <strong>

+1  A: 

You will have to remove the string within <strong> from string within <a> -

var testString = "<a> contents <strong>strong content</strong> </a>";
var doc = new HtmlDocument();
doc.LoadHtml(testString);
var strWithinAnchor = doc.DocumentNode.SelectSingleNode("/a").InnerText;
var strWithinStrong = doc.DocumentNode.SelectSingleNode("/a/strong").InnerText;
var resultString = strWithinAnchor.Replace(strWithinStrong, string.Empty);
Rohit Agarwal