0

i'm using a parsing library called 'simplehtmldom'. all i want to do is extract the textual contents of table cells. that's all! it seems so simple... everything i've tried results in the ENTIRE FRIGIN PAGE being dumped because apparently all of the primitives traverse the dom tree up, down, and sideways. here's a trivialised example of what i'm trying to do :

$saved = '';
foreach($html->find('tr') as $tr) {
    foreach($tr->find('td') as $td) {
        $contents = $td->plaintext;
        if ($saved) {
            echo "$saved : $contents<br>\n";
            $saved = '';
        }
        if (strstr($contents, 'Title') || strstr($contents, 'Author')) {
            $saved = $contents;
        }
    }
}

i've tried using 'plaintext', 'innertext', and 'text', but no matter what i try, i end up getting either endless loads of crap echoed out, or else nothing at all.

does anyone know how to use this parser ? or else could suggest an alternative to do what i want to do ?

david furst
  • 329
  • 4
  • 17

1 Answers1

0

CAVEAT - this is not really an answer, but rather an alternative.

i'm closing this question because i was able to solve the problem using a different approach, the DOM class, mentioned here. hopefully this will save someone some time if you're just looking for a way to get the contents of table cells and aren't constrained to a particular package or approach.

Community
  • 1
  • 1
david furst
  • 329
  • 4
  • 17