The sample runs the TclHtmlParser component and extracts inner HTML from specific tags.
 
 
private void button1_Click(object sender, EventArgs e)
{
	textBox2.Clear();

	htmlParser1.IncludeClosingTags = true;
	htmlParser1.ParseMethod = ParseMethod.All;
	htmlParser1.Parse(textBox1.Lines);

	for (int i = 0; i < htmlParser1.Tags.Count - 1; i++)
	{
		HtmlTag tag = htmlParser1.Tags[i];
		if (tag.Name == "div" 
                &&  tag.Attributes.AttributeValue("class") == "tvRow tvFirst hasLabel tvFirst")
		{
			textBox2.Text += GetInnerHtml(tag.Owner, tag) + "\r\n";
		}
	}
}
 
private string GetTagSource(HtmlTag tag) 
{
	string result;
	if (tag.IsClosingTag)
	{
		result = "</" + tag.Name + ">";
	}
	else
	if(tag.IsText)
	{
		result = tag.TagSource;
	}
	else
	{
		result = "<" + tag.TagSource + ">";
	}
	return result;
}

private string GetInnerHtml(HtmlTag owner, HtmlTag tag)
{
	string result;
	if (tag.NextTag != null && tag.NextTag.Owner != owner)
	{
		if (owner != tag.Owner)
		{
			result = GetTagSource(tag);
		}
		else
		{
			result = "";
		}

		result += GetInnerHtml(owner, tag.NextTag);
	}
	else
	{
		result = GetTagSource(tag);
	}
	return result;
}

Add Feedback