python/libxml2dom questions

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

    #1

    python/libxml2dom questions

    hi paul...

    in playing around with the test python app (see below) i've got a couple of
    basic questions. i can't seem to find the answers via google, and when i've
    looked in the libxml2dom stuff that i downloaded i didn't see answers
    either...

    for the list in the "for label in d.xpath" how can i find out the size of
    the list???? a simple/basic question, but it's driving me up a wall!!!

    also, how can i determine what methods are available for a libxml2dom
    object?

    thanks...

    -bruce

    sample code:
    --------------------------------

    --------------------------------#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()")

    print l[1].nodeValue

Working...