size of an array..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bruce

    #1

    size of an array..

    hi..

    another basic question...

    in the following:
    #test python script
    import libxml2dom
    import urllib

    print "hello"

    turl =
    "http://courses.tamu.ed u/ViewSections.as px?campus=CS&x= hvm4MX4PXIY9J8C 2Dcxz5
    0ncXTJdT7v2&typ e=M"

    f = urllib.urlopen( turl)
    s = f.read()
    f.close()
    # s contains HTML not XML text
    d = libxml2dom.pars eString(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



  • Barry Kelly

    #2
    Re: size of an array..

    "bruce" <bedouglas@eart hlink.netwrote:
    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

    --

    Comment

    Working...