[yunqa.de] DIHtmlParser with Table Plugin

  • From: KD <kdunlap@xxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Tue, 10 Jul 2012 11:18:30 -0500

Ralf,
  I'm not sure if I'm doing something wrong or what.

I have an ASP page (attached) that has 1 root table and 3 nested tables.
 I'm trying to grab the values from the 3rd and 4th table( or 2nd and 3rd
nested table).  I have a simple program for testing right now.

In the below sample, I expect to see DIHtmlTablesPlugin1.HtmlTable.Count go
above 2, but I never see that.  Is there something I'm doing wrong?

DIHtmlTablesPlugin1.HtmlRootTableCount <-- Hits 1, which I expect
DIHtmlTablesPlugin1.HtmlTables.Count <-- Highest count is 2, I would expect
3 and 4
DIHtmlTablesPlugin1.HtmlTableCount <- Hits 4, which I expect

I even tried using the Demo app to parse the HTML page and I can parse the
1st nested table but it won't parse the 2nd and 3rd nested table.  I've
changed the values in the Demo app to reflect which tables I expect it to
parse.



<pre style='color:#000000;background:#ffffff;'><span style='color:#800000;
font-weight:bold; '>begin</span>
<span style='color:#800000; font-weight:bold; '>procedure</span>
TForm1<span style='color:#808030; '>.</span>Button1Click<span
style='color:#808030; '>(</span>Sender<span style='color:#808030;
'>:</span> TObject<span style='color:#808030; '>)</span><span
style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>begin</span>
  DIHtmlParser1<span style='color:#808030; '>.</span>SourceStream <span
style='color:#808030; '>:</span><span style='color:#808030; '>=</span>
TFileStream<span style='color:#808030; '>.</span>Create<span
style='color:#808030; '>(</span><span style='color:#0000e6;
'>'C:\Users\kirkdmo\Documents\sbg6580.asp'</span><span
style='color:#808030; '>,</span> fmOpenRead <span style='color:#800000;
font-weight:bold; '>or</span> fmShareDenyWrite<span style='color:#808030;
'>)</span><span style='color:#800080; '>;</span>
  <span style='color:#800000; font-weight:bold; '>try</span>
    DIHtmlParser1<span style='color:#808030; '>.</span>Reset<span
style='color:#800080; '>;</span>
    DIHtmlParser1<span style='color:#808030; '>.</span>ParseAll<span
style='color:#800080; '>;</span>

  <span style='color:#800000; font-weight:bold; '>finally</span>
    DIHtmlParser1<span style='color:#808030; '>.</span>SourceStream<span
style='color:#808030; '>.</span>Free<span style='color:#800080; '>;</span>
  <span style='color:#800000; font-weight:bold; '>end</span><span
style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>end</span><span
style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>procedure</span>
TForm1<span style='color:#808030;
'>.</span>DIHtmlTablesPlugin1HtmlTablesChanged<span style='color:#808030;
'>(</span>
  <span style='color:#800000; font-weight:bold; '>const</span> Sender<span
style='color:#808030; '>:</span> TDIHtmlTablesPlugin<span
style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>var</span>
  HtmlTable<span style='color:#808030; '>:</span> TDIHtmlTable<span
style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>begin</span>
  Memo1<span style='color:#808030; '>.</span>Lines<span
style='color:#808030; '>.</span>Add<span style='color:#808030;
'>(</span><span style='color:#0000e6; '>'Root Tables: '</span> <span
style='color:#808030; '>+</span> IntToStr<span style='color:#808030;
'>(</span>DIHtmlTablesPlugin1<span style='color:#808030;
'>.</span>HtmlRootTableCount<span style='color:#808030; '>)</span><span
style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
  Memo1<span style='color:#808030; '>.</span>Lines<span
style='color:#808030; '>.</span>Add<span style='color:#808030;
'>(</span><span style='color:#0000e6; '>'Tables: '</span> <span
style='color:#808030; '>+</span> IntToStr<span style='color:#808030;
'>(</span>DIHtmlTablesPlugin1<span style='color:#808030;
'>.</span>HtmlTables<span style='color:#808030; '>.</span>Count<span
style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span
style='color:#800080; '>;</span>
  Memo1<span style='color:#808030; '>.</span>Lines<span
style='color:#808030; '>.</span>Add<span style='color:#808030;
'>(</span><span style='color:#0000e6; '>'Total Tables: '</span> <span
style='color:#808030; '>+</span> IntToStr<span style='color:#808030;
'>(</span>DIHtmlTablesPlugin1<span style='color:#808030;
'>.</span>HtmlTableCount<span style='color:#808030; '>)</span><span
style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
  Memo1<span style='color:#808030; '>.</span>Lines<span
style='color:#808030; '>.</span>Add<span style='color:#808030;
'>(</span><span style='color:#0000e6; '>' '</span><span
style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>end</span><span
style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>initialization</span>

  RegisterHtmlTags<span style='color:#800080; '>;</span>
RegisterHtmlAttribs<span style='color:#800080; '>;</span>
  RegisterHtmlDecodingEntities<span style='color:#800080; '>;</span>
  RegisterHtmlEncodingEntities<span style='color:#800080; '>;</span>
  RegisterCharSets<span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>end</span><span
style='color:#808030; '>.</span>
</pre>

Other related posts: