B
bruce
hi..
another basic question...
in the following:
#test python script
import libxml2dom
import urllib
print "hello"
turl =
"http://courses.tamu.edu/ViewSections.aspx?campus=CS&x=hvm4MX4PXIY9J8C2Dcxz5
0ncXTJdT7v2&type=M"
f = urllib.urlopen(turl)
s = f.read()
f.close()
# s contains HTML not XML text
d = libxml2dom.parseString(s, html=1)
# get the community-related links
for label in
d.xpath("/html/body/table/tr/td[2]/table/tr[6]/td/table/child::tr/td[@class=
'sectionheading']/text()"):
print label.nodeValue
print "/n/n/n/"
l =
d.xpath("/html/body/table/tr/td[2]/table/tr[6]/td/table/child::tr/td[@class=
'sectionheading']/text()")
xx = =sizeof(l)
print "test\n"
print "l = ".xx." \n"
print l[1].nodeValue
=========================================================
how do i determine the size of "l"
from the "for label in d.xpath", i assume that "d.xpath" is returning
multiple strings/objects/etc... and that label is assigned to the next
"element during the loop.
is there a way to determine the number of elements in "l", or the number of
iterations for the "for loop" prior to running it...
the tutorials i've seen as of yet haven't mentioned this..
thanks
-bruce
another basic question...
in the following:
#test python script
import libxml2dom
import urllib
print "hello"
turl =
"http://courses.tamu.edu/ViewSections.aspx?campus=CS&x=hvm4MX4PXIY9J8C2Dcxz5
0ncXTJdT7v2&type=M"
f = urllib.urlopen(turl)
s = f.read()
f.close()
# s contains HTML not XML text
d = libxml2dom.parseString(s, html=1)
# get the community-related links
for label in
d.xpath("/html/body/table/tr/td[2]/table/tr[6]/td/table/child::tr/td[@class=
'sectionheading']/text()"):
print label.nodeValue
print "/n/n/n/"
l =
d.xpath("/html/body/table/tr/td[2]/table/tr[6]/td/table/child::tr/td[@class=
'sectionheading']/text()")
xx = =sizeof(l)
print "test\n"
print "l = ".xx." \n"
print l[1].nodeValue
=========================================================
how do i determine the size of "l"
from the "for label in d.xpath", i assume that "d.xpath" is returning
multiple strings/objects/etc... and that label is assigned to the next
"element during the loop.
is there a way to determine the number of elements in "l", or the number of
iterations for the "for loop" prior to running it...
the tutorials i've seen as of yet haven't mentioned this..
thanks
-bruce