Forum Moderators: open
IF (and it's a big one) you used xhtml and it's guaranteed to be well structured (read: validates) you could use xml tools to do the parsing.
Otherwise you'll always have a chance for false decisions based on not so well structured input into the parser.
But a parser might look like:
- remove comments
- skip to the interesting div
- set level to 0
- start reading input and copy it to output
- if you meet a <div>: level++
- if you meed a </div>: level-- ; if level<0: skip till end.
Look at output to see it there's a <table> inside: if so: flag it