jkrukoff at ltgc.com
Thu Sep 4 00:14:48 CEST 2008
On Wed, 2008-09-03 at 13:36 -0700, bruce wrote:
> i apologize up front as this is really more of an xpath question..
> in my python, i'm using the xpath function to iterate/parse some html. i can
> do something like
> and get the number of nodes that have text
> i can then do something like
> and get the number of total nodes...
> by subtracting, i can get the number of nodes, without text.. is there an
> easier way??!!
> ie, if i have something like
> is there a way to get the count that there is a single "td" node with
Well, you could just do the test (and the count!) in the xpath
count( //tr/td[ text() != "" ] )
It sounds like you're not familiar with xpath? I would recommend the
O'Reilly XSLT book, it has an excellent introduction to xpath in chapter
John Krukoff <jkrukoff at ltgc.com>
Land Title Guarantee Company
More information about the Python-list