documents9900 has asked for the wisdom of the Perl Monks concerning the following question:
My second input file isRoot1 TBLA KEY1 COLA A B Root1 TBLA KEY1 COLB D E Root1 TBLA KEY3 COLX M N Root2 TBLB KEY4 COLX M N Root2 TBLB KEY4 COLD A B Root3 TBLC KEY5 COLD A B
My third input file isRoot1 TBLA KEY6 Root2 TBLB KEY7 Root3 TBLC KEY8
Root1 TBLA KEY9 Root1 TBLA KEY10 Root3 TBLC KEY11
Basically File representation is : 1) First file represents the old and new values. First is root table, Second is actual table in which diff is there. Third column tells the key value. Fourth and Fifth represents old and new value.
2) Second file represents the primary key which exists in db1 only and not in db2. First is root table, Second is actual table in which key exists. Third column tells the key value
3) Third file represents the primary key which exists in db2 only and not in db1. First is root table, Second is actual table in which key exists. Third column tells the key value
The output to be created in xml format asTHIS IS NOT COMPLETE OUTPUT. PART OF OUTPUT IS DISPLAYED Can anyone suggest what would be the best way to do this. Should i convert this text file to hash of hashes first and then try using pltoxml(). does this make sense. Can XML::Simple or XML::Writer suffice this.<Data> <Root1> <TBLA> <NEW1> <KEY>KEY6</KEY> <NEW1> <NEW2> <KEY>KEY9</KEY> <KEY>KEY10</KEY> <NEW2> <MODIFIED> <KEY name =KEY1> <COLA> <oldvalue>A</oldvalue> <newvalue>B</newvalue> </COLA> <COLB> <oldvalue>D</oldvalue> <newvalue>E</newvalue> </COLB> </KEY> <KEY name =KEY3> <COLX> <oldvalue>M</oldvalue> <newvalue>N</newvalue> </COLX> </KEY> </MODIFIED> </TBLA> </Root1> <Data>
This is the first time I am working on xml and not sure which approach will help efficicently my solution. A small example wrt to my req would be appreciated.
*Input file will always be sorted on Root and then TBLNAMEOutput format : Output contains for every root, every table in that root and that for every table, key which exists in one and then key which exists in second only. This comes in section new1 and new2 respectively. Third section contains Modified which needs to read from first input file and list the key value and with that key value what columns are modified (their old and new value)
If I have to use XML::Simple, how do i create hashref from these files which i can pass it to XMLout. There is no key in any of these files.I wrote a small piece of code which reads eah root from file1 and from that root reads all files and manually create the tags. Basically i tried creating my own XML parser.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML File Creation in Perl
by kcott (Archbishop) on Apr 16, 2013 at 15:48 UTC | |
by documents9900 (Initiate) on Apr 16, 2013 at 17:09 UTC | |
by kcott (Archbishop) on Apr 16, 2013 at 19:03 UTC | |
by documents9900 (Initiate) on Apr 17, 2013 at 05:26 UTC | |
by kcott (Archbishop) on Apr 17, 2013 at 06:34 UTC | |
| |
|
Re: XML File Creation in Perl
by hdb (Monsignor) on Apr 16, 2013 at 14:16 UTC | |
by documents9900 (Initiate) on Apr 16, 2013 at 14:47 UTC |