http://qs1969.pair.com?node_id=698289


in reply to Re^2: XML Tags Stripping & Calculating checksum on it
in thread XML Tags Stripping & Calculating checksum on it

my $data = do { local( $/ ) ; <$XmlFile> } ; # Slurp file $data =~ s!(^\s*)?\<(TotalAmount|NoOfRecords|TotalBatch|CurrentBatch|E +ODTransactionDate|BankFileSeqNo|TotAmount)\>(.+?)\<\/\1\>\n?!!mig; +# Zap headers $data =~ s!(^\s*)?</?.*?>\n?!!mig; # Zap xml tags CRC32($data); # CRC remaining data
Should be fast, but in general regex'ing x/html is fragile and NOT recommended.
(implicit assumptions about the data content is one of the traps, -- which may/not apply in your case).
You probably should use XML::Twig instead!