I have used below code to get the regex but not working properly.. Please suggest..
<?xml version='1.0'?> <root> <category cname='CH1' id='C1'> <subcat sname='SCName1' sid='SC1'> I want to get sname & sid attributes value of SCName1 & SC1. I've used below code
use File::Slurp; my $filename='nba.xml'; my @lines = read_file( $filename ) ; foreach (@lines) { $_=~/sname\s*=\s*'([^']+)'.*?sid\s*=\s*'([^']+)'/g; print "$1,$2\n"; $comp1="$1"; $comp2="$2"; } Thanks in advance!!!!!!