[XML-SIG] node identity with libxml2

Matt Patterson list-matt at reprocessed.org
Thu Jan 29 06:40:21 EST 2004


I'm using libxml2 and I'm trying to determine the intersection of two 
lists of nodes, where each list is a leaf-to-root chain of ancestors. 
The lists do have a point of intersection.

printing the trees shows this:

tree1: [<xmlNode (start) object at 0x6d788>, <xmlNode (alpha) object at 
tree2: [<xmlNode (end) object at 0x6d878>, <xmlNode (alpha) object at 

(I've snipped the ends of the lists for clarity.)

Now, I know that the <xmlNode (alpha) object> in each list are 
references to the same node: There's only one <alpha> element in the 
entire document. However, if I do tree1[1] == tree2[1] it returns 
false, which is a problem.

tree1[1]: <xmlNode (alpha) object at 0x6de18>
tree2[1]: <xmlNode (alpha) object at 0x6df08>
tree1[1] == tree2[1]: False

The leaf points of tree1 and tree2 and <start/> and <end/> respectively.


Is there any way to test nodes for identity?



    Matt Patterson | Typographer
    <matt at emdash.co.uk> | http://www.emdash.co.uk/
    <matt at reprocessed.org> | http://reprocessed.org/

More information about the XML-SIG mailing list