[XML-SIG] Accessing DOM nodes in Python

Dag Sunde dag@orion.no
Wed, 4 Oct 2000 22:50:07 +0200


Check Your argument to "getElementsByTagName"...

You ask for "isResultsInfo" (plural) (s)...
but your tag is defined as "<isResultInfo>" (singular)

Remove the "s" in: doc.getElementsByTagName("isResult_s_Info")
and you shold be ok... :-)

Dag.

----- Original Message -----
From: "Thomas Gagne" <tgagne@ix.netcom.com>
Cc: "Python XML-SIG" <xml-sig@python.org>
Sent: 4. oktober 2000 22:20
Subject: Re: [XML-SIG] Accessing DOM nodes in Python


> 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()
>
>     parser.setDocumentHandler(dh)
>
>     fh = StringIO.StringIO(buffer)
>     parser.parseFile(fh)
>
>     doc = dh.document
>     print doc.getElementsByTagName("isResultsInfo")
>
>     parser.close()
>     fh.close()
>
> and when I run it, I get:
>
> <isResult>
> <isResultInfo rows="-1" status="-6"></isResultInfo>
> </isResult>
>
> <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
>
> --
> .tom
>
>
>
>
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://www.python.org/mailman/listinfo/xml-sig



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

Admin
Orion System AS
**********************************************************************