really basic question regarding arrays/function output...

bruce bedouglas at earthlink.net
Sat Jul 1 18:30:47 EDT 2006


hi...

i have the following test python script.... i'm trying to figure out a
couple of things...

1st.. how can i write the output of the "label" to an array, and then how i
can select a given element of the array.. i know real basic..

2nd.. where can i go to find methods of libxml2dom. i've been looking using
google, but can't seem to find a site pointing out the underlying methods,
which is kind of strange...

-bruce



-------------------------------------
test.py
#! /usr/bin/env python

#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





More information about the Python-list mailing list