libxml2 and node identity

Discussion in 'Python' started by Victor Ng, Jun 17, 2004.

  1. Victor Ng

    Victor Ng Guest

    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!
    Victor Ng, Jun 17, 2004
    #1
    1. Advertising

  2. Victor Ng

    Victor Ng Guest

    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!
    >
    >
    Victor Ng, Jun 23, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,450
  2. Giovanni Bassi
    Replies:
    0
    Views:
    645
    Giovanni Bassi
    Oct 20, 2003
  3. nalbayo
    Replies:
    2
    Views:
    5,498
    Bruce Barker
    Nov 11, 2005
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,425
    Dimitre Novatchev
    Aug 24, 2006
  5. Frederick D'hont
    Replies:
    0
    Views:
    306
    Frederick D'hont
    Jul 25, 2005
Loading...

Share This Page