I have a text file in the following form and i want to store it in 2-d array. After that i have to generate a XMLfile using the elements of array.
Please tell me :how store this file in the form of 2-d array and then howto generate XML file using that array...all coding has to be done in bash shell
Text file: Let Name be : Test.txt
Abc Def Ghi Jkl
Lmn Nop Qrs Tuv
... ... ... ...
... ... ... ... (anynumber of records )
Then XML format is known to me i to generate XMLfile using that array elements...
Note : You can suggest any other form of data structure for storing information (Text File) but should be 2-d ,but please also mention about how to generate XMLfile ...
{ J=1
echo '<data>'
while read LINE
do
VAR=( $LINE )
echo '<Field'$J' name="'${VAR[0]}'"><\Field'$J'>'
for I in 1 2 3
do echo '<OtherField name="'${VAR[$I]}'"><\Otherfield>'
done
echo '<\Field>'
done < InputFile1
echo '<\data>'
} > OutputFile.xml
This code is not working ... i am using name of my file instead
of flatfile .. plzz tell me way to execute this file..
like what should be the extension what should be the command for executing this file
---------- Post updated at 10:25 PM ---------- Previous update was at 10:16 AM ----------
thanks for helping me .. but i have to store the contants of that file in a data structure ... plzz tell me a way to store the contents in data structure and then generate aXML file form it..
Sorry for spoiling the discussion at the last moment.
This is not a scalable and fail proof way to create XML formats. Instead well supported already created modules are available from CPAN
Probably you could start of with XML::Simple