use Utils::XMLUtils qw(loadXMLFile
getNodesFromPath
getNodeFromPath
getChildren
getNodeName
getValueFromPath
getValuesFromPath
checkIfExists
createXMLDocument
createNewElement
assignChild
createTextElement
wrtiteTofile
);
use Digest::SHA1 qw(sha1);
sub getHexData {
my ($key)= unpack("H*",shift);
return $key;
}
print "Enter the file path :";
my $file = <STDIN>;
chomp($file);
print "Enter chunk size :";
my $size = <STDIN>;
chomp($size);
open(FILE, $file) || die "Unable to open the file";
my $doc = createXMLDocument();
my $SigData = createNewElement($doc, "SigData");
$len = read(FILE, $data, $size);
while ( $len != 0) {
$datalen = $size == $len ? $size: $len;
$digest = sha1($data);
$keydata = getHexData($digest);
$data = getHexData($data);
$kvpair = createNewElement($doc, "KVPair");
$key = createNewElement($doc, "Key");
$keytext = createTextElement($doc, $keydata);
assignChild($key, $keytext);
$Value = createNewElement($doc, "Value");
$Valuetext = createTextElement($doc, $data);
assignChild($Value, $Valuetext);
assignChild($kvpair, $key);
assignChild($kvpair, $Value);
assignChild($SigData, $kvpair);
$len = read(FILE, $data, $size);
}
wrtiteTofile($SigData,"sample.xml",0);
close(FILE);
I have a Programme above like this, which will take a file and create keys and values and append to a XML File.
I have written functions for all this XML utilities.
LoadXMLFile,getNodesFromPath,getNodeFromPath
,getChildren
getNodeName,getValueFromPath,getValuesFromPath,checkIfExists
createXMLDocument,createNewElement,assignChild,createTextElement
wrtiteTofile
while i try to do for big files (more than 1gb), Big XML is being created as expected. But the problem is to process this huge XML data, into some other programme it is taking much longer time. So i am looking to append the generated key and values to a flat text file. How can i do this. Please help.
a Big Thanks in advance.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.