koti688 has asked for the wisdom of the Perl Monks concerning the following question:

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.

Replies are listed 'Best First'.
Re: Help Regd Flat File
by Corion (Patriarch) on Mar 31, 2009 at 18:16 UTC

    You might want to point out that this is in succession to Which is Best ? XML or Textpad, in which thread you also mention the Utils::XMLUtils package.

    You also mention there that the output you want is basically:

    <SigData> <KVPair> <Key>...</Key> <Value>..</Value> </KVPair> </SigData> <SigData> <KVPair> <Key>....</Key> <Value>..</Value> </KVPair> </SigData>

    so I wonder, why aren't you simply using print statements to print out the XML you want?