[XML-SIG] Accessing DOM nodes in Python

Thomas Gagne tgagne@efinnet.com
Wed, 04 Oct 2000 16:20:59 -0400

Andrew Kuchling wrote:

> On Wed, Oct 04, 2000 at 04:04:39PM -0400, Thomas Gagne wrote:
> >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.
> dh is a SAX document handler, not a DOM tree, so I wouldn't expect
> get_parentNode() to work.  Instead say "doc = dh.document"; doc is
> then a DOM tree, so you can call doc.getElementsByTagName() or
> whatever.

That sounded good so I tried it.  The code now looks like:

def isResultValue(buffer):
    print buffer
    parser = saxexts.make_parser()

    dh = SaxBuilder()


    fh = StringIO.StringIO(buffer)

    doc = dh.document
    print doc.getElementsByTagName("isResultsInfo")


and when I run it, I get:

<isResultInfo rows="-1" status="-6"></isResultInfo>

<NodeList []>

Now, looking at the buffer I can see there's a <isResultInfo> node, but it
*never* seems to show up.  It's driving me nuts!!!

> --amk
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://www.python.org/mailman/listinfo/xml-sig