Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found