Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML::LibXML - detect if two Elements are the same?

I'm working with XML::LibXML in Perl.

Say I have two $element references gotten by different (opaque) XPath queries.

(How) can I determine, if the two $element (Node) refs are the same element in the document tree?

Comparing $el1 == $el2doesn't always work as far as I could tell.

like image 432
Martin Ba Avatar asked Aug 26 '11 13:08

Martin Ba


1 Answers

It's in the XML::LibXML::Node documentation:


isSameNode

$bool = $node->isSameNode( $other_node );

returns TRUE (1) if the given nodes refer to the same node structure, otherwise FALSE (0) is returned.

like image 101
Zaid Avatar answered Sep 23 '22 16:09

Zaid