Re: [xml] Building a DOM tree in python using libxml2
- From: Daniel Veillard <veillard redhat com>
- To: "William M. Brack" <wbrack mmm com hk>
- Cc: xml gnome org
- Subject: Re: [xml] Building a DOM tree in python using libxml2
- Date: Thu, 15 Jul 2004 03:51:46 -0400
On Thu, Jul 15, 2004 at 12:16:25PM +0800, William M. Brack wrote:
Colin - Sorry not to have replied to your original post, but I had
the same problem as you with not having any examples of a simple
Python program that worked :-). John's example solves that problem.
I'll try to check into why your previous attempt produced a
segfault - we can argue over whether or not the code is "correct",
but I think we will agree it shouldn't crash in that manner.
In fact, I simplified your original post just a bit:-
import libxml2
d = libxml2.xmlDoc('1.0')
print d
and got a segfault at that point :-\. Anyway, I'll try to get it
fixed.
Here is the associated code. It's generated code. the xmlDoc and other
classes are wrappers for a libxml2 object and must be created with such
an object. As pointed by the working example you must use a library
call to create those objects.
class xmlDoc(xmlNode):
def __init__(self, _obj=None):
self._o = _obj
xmlNode.__init__(self, _obj=_obj)
xmlNode.__init__ could check for the type of the object an raise an
exception, that would be one way to catch those kind of mistakes.
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]