469,643 Members | 1,270 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

libxml2 and node identity

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!
Jul 18 '05 #1
1 1836
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!


Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Juergen R. Plasser | last post: by
reply views Thread by Richard Mertens | last post: by
5 posts views Thread by Rene Olsthoorn | last post: by
1 post views Thread by bdecker | last post: by
2 posts views Thread by nickheppleston | last post: by
1 post views Thread by cesar.ortiz | last post: by
2 posts views Thread by jianbing.chen | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.