in reply to File parsing with HTML::TokeParser::Simple

The problem is that you're trying to use the tool in a way it can't be used. Consider the following process instruction:

<? echo 'This is from PHP.'; ?>

That runs over three lines. However, if you're reading things in line-by-line, you lose all context. When HTS gets to an individual line, it can't parse it as a process instruction because it doesn't know that it is one. I'm afraid you'll have to take a different approach to solving your problem.

I'm not sure there is a way around this problem, frankly, because the tokens will never have a direct correlation with line numbers. One possibility would be to (forgive me!) track the number of line endings in all tokens as a rough heuristic of which line a token is on.

Cheers,
Ovid

New address of my CGI Course.

Replies are listed 'Best First'.
Re^2: File parsing with HTML::TokeParser::Simple
by THRAK (Monk) on Feb 24, 2005 at 20:19 UTC
    Ah. Now that makes sense. I need to know the line numbers because I'm using this information to build a report of what is wrong in the file. Will need to rethink this (yet again). I guess I'll start with trying to process using HTS file constructor and count newlines as I go.

    You really should make HST keep track of what line it is on...because that's what I need!  ;)

    Other suggestions on how to build this wheel would be more than welcome. Thanks Ovid.