B
bruce
hi...
using libxml2dom as the xpath lib
i've got a situation where i can have:
foo=a.xpath( /html/body/table[2]/tr[45]/td)
and i can get
11 as the number of returned td elements for the 45th row...
this is as it should be.
however, if i do:
foo=a.xpath( /html/body/table[2]/tr)
and then try to iterate through to the 45th "tr", and try to get the number
of "td" elements..
i can't seem to get the additional xpath that has to be used,
i've tried a number of the following with no luck...
l1 = libxml2dom.toString(tmp_[0])
print "l1 = "+l1+"\n"
ldx = 0
for l in tmp_:
print "ld ="+str(ldx)
if ldx==45:
#needs to be a better way...
#l1 = libxml2dom.toString(tmp_[0])
l1 = libxml2dom.toString(l)
#print "1111 = ",l1
q1 = libxml2dom
b1 = q1.parseString(l1, html=1)
#dd1 = b1.xpath("//td[not(@width)]")
#data = b1.xpath("//td/font")
#data = b1.xpath("//td[@valign='top'][not(@width)]")
#data =
b1.xpath("//child::td[position()>0][@valign='top'][not(@width)]")
#data = b1.xpath("//td/parent::*/td[@valign='top'][not(@width)]")
#data = b1.xpath("//td[position()]")
#data = b1.xpath("//parent::tr[position()=1]/td")
data = b1.xpath("//td[@valign='top'][not(@width)]")
it appears that i somehow need to get the direct child/node of the parent
"tr" that's the "td"...
it looks like using ("//td..." gets all the underlying child "td"... as
opposed to the direct
1st level child/siblings... any thoughts/pointers would be appreciated...
thanks...
using libxml2dom as the xpath lib
i've got a situation where i can have:
foo=a.xpath( /html/body/table[2]/tr[45]/td)
and i can get
11 as the number of returned td elements for the 45th row...
this is as it should be.
however, if i do:
foo=a.xpath( /html/body/table[2]/tr)
and then try to iterate through to the 45th "tr", and try to get the number
of "td" elements..
i can't seem to get the additional xpath that has to be used,
i've tried a number of the following with no luck...
l1 = libxml2dom.toString(tmp_[0])
print "l1 = "+l1+"\n"
ldx = 0
for l in tmp_:
print "ld ="+str(ldx)
if ldx==45:
#needs to be a better way...
#l1 = libxml2dom.toString(tmp_[0])
l1 = libxml2dom.toString(l)
#print "1111 = ",l1
q1 = libxml2dom
b1 = q1.parseString(l1, html=1)
#dd1 = b1.xpath("//td[not(@width)]")
#data = b1.xpath("//td/font")
#data = b1.xpath("//td[@valign='top'][not(@width)]")
#data =
b1.xpath("//child::td[position()>0][@valign='top'][not(@width)]")
#data = b1.xpath("//td/parent::*/td[@valign='top'][not(@width)]")
#data = b1.xpath("//td[position()]")
#data = b1.xpath("//parent::tr[position()=1]/td")
data = b1.xpath("//td[@valign='top'][not(@width)]")
it appears that i somehow need to get the direct child/node of the parent
"tr" that's the "td"...
it looks like using ("//td..." gets all the underlying child "td"... as
opposed to the direct
1st level child/siblings... any thoughts/pointers would be appreciated...
thanks...