public void MatchCount() { HtmlProfiler profiler; int count; // Normal test HtmlSectionTemplate template = new HtmlSectionTemplate(); template.Tags = "T"; template.Template = "<table><tr><td>Test</td><td>1</td><td>2</td></tr></table>"; profiler = new HtmlProfiler(template); count = profiler.MatchCount( "<table><tr><td>Test</td><td>1</td><td>2</td></tr></table><div><div><div><table><tr><td>Test</td><td>1</td><td>2</td></tr></table><span><span><span><table><tr><td>Test</td><td>1</td><td>2</td><td>3</td></tr></table>"); Assert.IsTrue(count == 2); // Regex test template.Template = "<table><tr><td>Test</td><td>1</td><td>2</td><Z(><td>3</td></Z)?></tr></table>"; profiler = new HtmlProfiler(template); count = profiler.MatchCount( "<table><tr><td>Test</td><td>1</td><td>2</td></tr></table><div><div><div><table><tr><td>Test</td><td>1</td><td>2</td></tr></table><span><span><span><table><tr><td>Test</td><td>1</td><td>2</td><td>3</td></tr></table>"); Assert.IsTrue(count == 3); }
/// <summary> /// Initializes a new instance of the <see cref="HtmlParser"/> class. /// </summary> /// <param name="template">The template.</param> /// <param name="parserDataType">Type of the parser data.</param> /// <param name="parserDataArgs">The parser data args.</param> public HtmlParser(HtmlParserTemplate template, Type parserDataType, params object[] parserDataArgs) { _template = template; _dataType = parserDataType; _dataArgs = parserDataArgs; _sectionSource = string.Empty; _profiler = new HtmlProfiler(_template.SectionTemplate); _sectionParser = new HtmlSectionParser(_template.SectionTemplate); }