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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.