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



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel Veillard wrote:
| 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
|

It'd be nice actually if _obj was None that the appropriate library call
got made to manufacture it.

cf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA9zLooaQ1/feGlJoRAjKgAJ93d9NqfagvH+80ee+omdathmsGdQCfU/O+
frq+BstMfPu6CELHen4VHes=
=kcaS
-----END PGP SIGNATURE-----



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