sub xpath_sort {
my($self, @xpaths) = @_;
my %canon;
foreach my $xpath (@xpaths) {
my $c = $xpath;
$c =~ s{\[(\d+)\]}{'[' . sprintf("%05d", $1) . ']'}e;
$canon{$xpath} = $c;
}
@xpaths = sort { $canon{$a} cmp $canon{$b} } @xpaths;
return @xpaths;
}
XPath rocks. I can't imagine XML without it anymore...
Triplets! (Score:2)
Why not create triplets (XPath, char content, order number) instead of just pairs?
mirod
Re:Triplets! (Score:2)
no solution (Score:2)
I don't think there's a solution to your problem, apart from having a way of creating the nodes not in order (and using ghost nodes) which would be a great thing to have.
XPath rocks. I can't imagine XML without it anymore...
Be careful... you're getting very dangerously close to liking XSLT...
-- Robin Berjon [berjon.com]