Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: XML Tags Stripping & Calculating checksum on it

by harishnuti (Beadle)
on Jul 16, 2008 at 13:29 UTC ( #697969=note: print w/replies, xml ) Need Help??


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


First of all a big thanks for putting effort on my query

my purpose of calculating checksum in above fashion is to achieve matching of checksum from my client, they do this in above fashion in java.iam trying to improve performance of my script retaining the final checksum to be same.

if i calculate incremental checksum , how can i get the final checksum which can be matched by our client?
  • Comment on Re^2: XML Tags Stripping & Calculating checksum on it

Replies are listed 'Best First'.
Re^3: XML Tags Stripping & Calculating checksum on it
by Perlbotics (Bishop) on Jul 16, 2008 at 15:19 UTC
    If you use i.e. the String::CRC32 module, just use the incremental form $crc=crc32($additionalString,$crc) starting with $crc=0;. Finally, $crc is a 32bit unsigned integer value that can be compared. Maybe you need a conversion into a hex-notation or something beforehand (Edit: I mean before comparison, if you have to compare against some string format.): $clear=sprintf("%X",$crc); or $clear=uc(unpack("H8", pack("N",$crc)));
Re^3: XML Tags Stripping & Calculating checksum on it
by ady (Deacon) on Jul 17, 2008 at 13:00 UTC
    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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://697969]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2022-09-30 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (126 votes). Check out past polls.

    Notices?