libxml2 and node identity

Victor Ng vng1 at mac.com
Wed Jun 23 13:35:30 CEST 2004


Ok - well I got a reply from Daniel Veillard, there's no way to properly 
get the identity of a node in libxml2 by using the standard Python bindings.

This is a really bad since it allows you to leak memory very easily.  If you 
can't properly determine node identity, then you don't know if it's safe to 
free the node's memory.

vic


Victor Ng wrote:
> I've been trying to find information with how to figure out node 
> identity in libxml2 - but I'm at a loss.  I can't seem to find what I'm 
> looking for on the xmlsoft.org site and google doesn't seem to help at 
> all with the following query:
> 
> http://www.google.com/search?q=libxml2+node+identity
> 
> Here's a snippet to show the problem:
> 
>  >>> import libxml2
>  >>> doc = libxml2.newDoc('1.0')
>  >>> root = doc.newChild(None, 'root', None)
>  >>> print root, doc.children
> <xmlNode (root) object at 0x419c60> <xmlNode (root) object at 0x4710d0>
>  >>> print root._o, doc.children._o
> <PyCObject object at 0x221d0> <PyCObject object at 0x22170>
> 
> What I'd _like_ to do is to be able to check that two nodes are actually 
> identical.  The Python wrappers as well as the PyCObject references 
> don't seem to match up.  I also can't seem to find any way to do 
> something like "node.isSameNode(otherNode)"
> 
> Help!
> 
> 






More information about the Python-list mailing list