public void ParseSection2()
    {
      // Start and End for tag
      HtmlSectionTemplate template = new HtmlSectionTemplate();
      template.Tags = "T";
      template.Template =
        "<table><tr><td>Title:<#TITLE>(</td><td><#START></td><td><#DESCRIPTION></td><Z(><td><#GENRE></td></Z)?></tr></table>";

      HtmlSectionParser elements = new HtmlSectionParser(template);

      ParserData data = new ParserData();
      IParserData idata = (IParserData)data;
      string source = "<table><tr><td>Test</td><td>123</td><td>blah blah</td></tr></table>";
      elements.ParseSection(source, ref idata);

      Assert.IsTrue(data.GetElement("#TITLE") == "Test");
      Assert.IsTrue(data.GetElement("#START") == "123");
      Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");

      data = new ParserData();
      idata = (IParserData)data;
      source = "<table><tr><td>Title:Test(1:2)</td><td>123</td><td>blah blah</td></tr></table>";
      elements.ParseSection(source, ref idata);

      Assert.IsTrue(data.GetElement("#TITLE") == "Test");
      Assert.IsTrue(data.GetElement("#START") == "123");
      Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");
    }
예제 #2
0
 /// <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);
 }
예제 #3
0
 /// <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);
 }
    public void ParseSection3()
    {
      // Multiple tags
      HtmlSectionTemplate template = new HtmlSectionTemplate();
      template.Tags = "T";
      template.Template =
        "<table><tr><td><#TITLE>-<#SUBTITLE></td><td><#START></td><td><#DESCRIPTION></td><Z(><td><#GENRE></td></Z)?></tr></table>";

      HtmlSectionParser elements = new HtmlSectionParser(template);
      ParserData data = new ParserData();
      IParserData idata = (IParserData)data;
      string source = "<table><tr><td>Test-Sub</td><td>123</td><td>blah blah</td></tr></table>";
      elements.ParseSection(source, ref idata);

      Assert.IsTrue(data.GetElement("#TITLE") == "Test");
      Assert.IsTrue(data.GetElement("#SUBTITLE") == "Sub");
      Assert.IsTrue(data.GetElement("#START") == "123");
      Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");
    }