size of an array..

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
 
B

Barry Kelly

bruce said:
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..

Have you tried len(object)?

-- Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top