astarocean wrote: > using pyparsing to deal with nested tables , wanna keep table's > structure and propertys . > but program was chunked with the </td> tag of inner table. > > have any ideas? > > here's the program > > > from pyparsing import * <... snip ...> > > tablePattern = Forward() <... snip ...> > tablePattern = getMultiLevelPattern('table',trPattern) > t = tablePattern > for toks,strt,end in t.scanString(mytable): > print toks.asList() >
Load Forward's with '<<' instead of '='. Change: tablePattern = getMultiLevelPattern('table',trPattern) to: tablePattern << getMultiLevelPattern('table',trPattern) I think that is all you needed. Awesome job! (Also check out the pyparsing built-ins for making HTML and XML tags.) -- Paul -- http://mail.python.org/mailman/listinfo/python-list