Hi Monks,


i have a unique requirement for calculating checksum on a XML file as below

* Read the whole XML file
* Strip of all XML tags
* Bring all XML data into one line
* Will call CRC32 routine to calculate checksum on this one line
to Achieve this iam doing below

my $tempContent = undef; # Holds final XML data in one line while (<FILE>){ my $xml = $_; chomp($_); while($xml=~m/\<(.+?)\>(.+?)\<\/\1\>/sig){ my $tag=lc(strip($1)); ## Below line is the selective condition to ignore all + header XML tags and consider only data next if ( $tag =~ /TotalAmount|NoOfRecords|TotalBatch| +CurrentBatch|EODTransactionDate|BankFileSeqNo|TotAmount/i ); my $attribs="?"; my $value=strip($2); $tempContent .= qq~$value~; } $tempContent .= qq~\n~; open(OUT,">tmp") or die "Unable to open $! \n"; print OUT $tempContent; close OUT; CRC32 ( tmp) ; # this one can be ignored , i have no problem here #Showing on trasaction, but in daily there are plenty __DATA__ <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> # FInal data will be as below 1001298989890008876S MARR SON ABG89097INR0000000000221000000.002008-07 +-10T12:04:252008-07-10/CUST/ADH7870822/FRASER TRANSACTION17801000N1 # Will calculate checksum for above one line

my problem is, is there any better way to do above ? also , when XML file contains around 10,000 or more trasactions, its taking more time since iam processing line by line and appending in temp variable. pls let me know if i can improve in any of the above areas

In reply to XML Tags Stripping & Calculating checksum on it by harishnuti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.