Re: [xml] Building a DOM tree in python using libxml2

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

  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 Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]