[XML-SIG] Element.firstChild() returns error
Tue, 7 Nov 2000 15:09:55 -0800
Thanks Martin. I am able to 'get around' in Python/XML now. I did bump into
the Unicode issue and solved it with .encode("UTF-8"). I guess that's the
way it's done.
Thanks for your time.
> -----Original Message-----
> From: Martin v. Loewis [mailto:email@example.com]
> Sent: Monday, November 06, 2000 4:23 PM
> To: firstname.lastname@example.org
> Cc: email@example.com
> Subject: Re: [XML-SIG] Element.firstChild() returns error
> > By pawing around in the code, I discovered that instead of using
> > getFirstChild() I should use firstChild() on a Node. So first
> > question, is there a documented Python language binding to the DOM?
> There will be RSN. Unfortunately, it was not completed in time for
> 2.0, and currently sits on a machine at BeOpen which is currently
> The core of your problem here is that IDL attributes map to attributes
> in Python, instead of accessor functions as in Java. For compatibility
> with the Python CORBA mapping, 4DOM also supports the an accessor
> function _get_<name>.
> > >>> acctList1
> > <Element Node at 9131308: Name = 'Accounts' with 0 attributes and 3
> > children>
> > >>> acctList1.firstChild()
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in ?
> > AttributeError: no __call__ method defined
> > Is this an error in the implementation or in my use?
> It's your use. accList1.firstChild *is* the first child, no need to
> call it.
> > Finally, I noticed the javadom.py module. The comments indicate that
> > this module is to allow access to Java implementations from
> > Python. What I was hoping for was a wrapper to provide the Java IF's
> > to the Python implementation! Is this a reasonable request or am I
> > up the wrong tree?
> No, I believe that's something different: It gives you access to a
> Java DOM implementation inside JPython, with exposes the official
> Python DOM mapping of the Java DOM tree (instead of the one resulting
> from the Java mapping).
> However, it should not be too difficult to get used to this mapping;
> apart from the attributes issue, there really is no deviation from the
> straight-forward mapping (except that DOMStrings can sometimes appear
> as Unicode strings and sometimes as byte strings - depending on the
> Python version).
> One more difference, perhaps: the Python mapping offers convenience
> container objects instead of following the IDL-style containers: e.g.
> a NodeList might be accessible as a Python sequence. "might be", since
> it is a list in minidom (i.e. no .item, .length), and an object
> following the IDL mapping in 4DOM (i.e. no __getitem__, __len__). I
> hope this can be fixed so that you can always treat .childNodes as a
> list. If you only use .firstChild, .nextSibling, you won't even
> notice that difference.
> XML-SIG maillist - XML-SIG@python.org