Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: XML Tags Stripping & Calculating checksum on it

by Anonymous Monk
on Jul 16, 2008 at 07:29 UTC ( [id://697880]=note: print w/replies, xml ) Need Help??


in reply to XML Tags Stripping & Calculating checksum on it

I think this is better
#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; use Digest; my $xml = q~<Transaction> <MessageCode>100</MessageCode> <ToAccountNo>12989898900</ToAccountNo> <ToBranchCode>08876</ToBranchCode> <FromAccountNo>S MARR SON </FromAccountNo> <FromBranchCode>ABG89097</FromBranchCode> <CurrencyCode>INR</CurrencyCode> <Amount>0000000000221000000.00</Amount> <TransactionDate>2008-07-10T12:04:25</TransactionDate> <ValueDate>2008-07-10</ValueDate> <CustomerRefNo>/CUST/</CustomerRefNo> <ReferenceNo1>ADH7870822</ReferenceNo1> <ReferenceNo2>/FRASER TRANSACTION</ReferenceNo2> <DealerCode>1780</DealerCode> <SalesOrganisation>1000</SalesOrganisation> <TransactionType>N</TransactionType> <SequenceNo>1</SequenceNo> </Transaction>~; { my $ctx = Digest->new('SHA1');# MD5 ... my $t = new XML::Twig( TwigHandlers=> { Transaction => sub { print $_->children_text,$/; $ctx->add($_->children_text); } } ); $t->parse($xml); print $/, $ctx->hexdigest,$/; undef $ctx; undef $t; } __END__ 1001298989890008876S MARR SON ABG89097INR0000000000221000000.002008-07 +-10T12:04:252008-07-10/CUST/ADH7870822/FRASER TRANSACTION17801000N1 e5dc8115e0a2c22ffd034e07d4db8446b9d6696e # FInal data will be as below 1001298989890008876S MARR SON ABG89097INR0000000000221000000.002008-07 +-10T12:04:252008-07-10/CUST/ADH7870822/FRASER TRANSACTION17801000N1

Replies are listed 'Best First'.
Re^2: XML Tags Stripping & Calculating checksum on it
by harishnuti (Beadle) on Jul 16, 2008 at 13:16 UTC

    Thanks for the approach, but iam thinking how can i achieve the below functionality...
    next if ( $tag =~ /TotalAmount|NoOfRecords|TotalBatch|CurrentBatch|EOD +TransactionDate|BankFileSeqNo|TotAmount/i );

    The above are some tags which i want to exclude from being a part fo checksum calculation.. iam browsing XML::Twig doc still not sure how to achieve functionality

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-23 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found