After lunch I hacked this up that solves my problem. But there must be a better way...
sub _cmpXML( $$ ){ # Pass in two XML nodes and return 0 if they are the same, else # lexographically compare the namespaces fist then the node names # (with out prefexes) my $n1 = shift or die; my $n2 = shift or die; my $ns1 = $n1->namespaceURI(); my $ns2 = $n2->namespaceURI(); $ns1 ne $ns2 and return $ns1 cmp $ns2; my $nn1 = $n1->nodeName(); my $nn2 = $n2->nodeName(); $nn1 =~ s/^[^\:]*:?//; $nn2 =~ s/^[^\:]*:?//; return $nn1 cmp $nn2; }
There must be a built in for doing this, it is a bit inconceivable to me that this is not a common requirement
In reply to Re: Comparing nodes in LibXML
by worik
in thread Comparing nodes in LibXML
by worik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |