Accessing DOM nodes in Python
Thomas Gagne
tgagne at ix.netcom.com
Wed Oct 4 15:19:21 EDT 2000
I was just going through the XML howto about creating DOMs. I have a buffer
that looks like:
<isResult>
<isResultInfo rows="-1" status="-6"/>
</isResult>
And I want to get the value of the "status" attribute. My subroutine looks
like:
def isResultValue(buffer):
print buffer
parser = saxexts.make_parser()
dh = SaxBuilder()
parser.setDocumentHandler(dh)
fh = StringIO.StringIO(buffer)
parser.parseFile(fh)
print dh.get_parentNode()
parser.close()
fh.close()
Now, the problem is, I don't know how to get the first node from dh. I
usually try to print variables to see what they can do, but I'm not seeing
anything when I try "print dh". I've tried printing dh.parentNode and
dh.get_parentNode() without success. I think if someone could just point me
in the right direction I'd be zooming right along.
--
.tom
More information about the Python-list
mailing list