First page Back Continue Last page Overview Graphics
XXX: Some Ugliness
-
sub getAttributes
-
{ # return a NamedNodeMap when called by XML::DOM, an array when called by XML::XPath
$_[0]->[_A] ||= XML::DOM::NamedNodeMap->new (Doc => $_[0]->[_Doc], Parent => $_[0]);
-
unless( caller(0)=~ m{^XML::XPath})
-
{ # the original XML::DOM value, a NamedNodeMap object
return $_[0]->[_A];
}
-
else
-
{ # this is what XML::XPath needs: an array
-
my $elt= shift;
my @atts= grep { ref $_ eq 'XML::DOM::Attr' } values %{$elt->[1]};
$_->[$parent_field]= $elt foreach (@atts);
return wantarray ? @atts : \@atts;
}
}