my $xpath = 'BoringNode[1]/InterestingNode[@InterestingAttribute="outgrabe"]/AnotherBoringNode[@BoringAttribute="grey"]'; print $xpath =~ /InterestingNode\[[^"]+\"([^"]+)\"\]/;