in reply to Comparing nodes in LibXML
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing nodes in LibXML
by tangent (Parson) on Sep 03, 2015 at 02:05 UTC | |
by worik (Sexton) on Sep 03, 2015 at 02:56 UTC | |
by tangent (Parson) on Sep 03, 2015 at 03:05 UTC | |
by worik (Sexton) on Sep 03, 2015 at 20:16 UTC |