Vijay81 has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I am new to perl. am trying achive something wrt to xml file. I have input file that is an csv which has number of rows with data and have xml template file where in which i need to update the values read from csv file. am not sure where and how to update an xml file using csv file in perl. Can any one please help me out.
Input put file looks like : file name : abc.csvXml file looks like : Filename : std.xmlprotocol,host,port and commandline SSH,-P,22 103.243.543.233,erted SSH,-P,22 303.233.542.622,rrertd
In the above xml file, protocol,host,port and commandline tag values are updated from csv file. Output file which am looking for is :<!-- The following lines can be modified at your own risks. --> <configuration version="0.2.1.4" savepassword="True"> <root type="database" name="WSSS" expanded="True"> <container type="folder" name="CM" expanded="True"> <container type="folder" name="1-AD/M" expanded="True"> <connection type="PuTTY" name="WSSS"> <connection_info> <name>WSSSS</name> <protocol>SSH</protocol> <host>20.148.24.2</host> <port>22</port> <session>Default Settings</session> <commandline>EEREd</commandline> <description /> </connection_info> <login> <login /> <password /> <prompt /> </login> <timeout> <connectiontimeout>1000</connectiontimeout> <logintimeout>750</logintimeout> <passwordtimeout>750</passwordtimeout> <commandtimeout>750</commandtimeout> </timeout> <command> <command1 /> <command2 /> <command3 /> <command4 /> <command5 /> </command> <options> <loginmacro>False</loginmacro> <postcommands>False</postcommands> <endlinechar>10</endlinechar> </options> </connection> </root> </configuration>
<?xml version="1.0" encoding="utf-16"?> <!-- ****************************************************************- +-> <!-- * *- +-> <!-- * PuTTY Configuration Manager save file - All right reserved. *- +-> <!-- * *- +-> <!-- ****************************************************************- +-> <!-- The following lines can be modified at your own risks. --> <configuration version="0.2.1.4" savepassword="True"> <root type="database" name="WSSS" expanded="True"> <container type="folder" name="CM" expanded="True"> <container type="folder" name="1-AD/M" expanded="True"> <connection type="PuTTY" name="WSSS"> <connection_info> <name>WSSSS</name> <protocol>SSH</protocol> <host>103.243.543.233</host> <port>22</port> <session>Default Settings</session> <commandline>erted</commandline> <description /> </connection_info> <login> <login /> <password /> <prompt /> </login> <timeout> <connectiontimeout>1000</connectiontimeout> <logintimeout>750</logintimeout> <passwordtimeout>750</passwordtimeout> <commandtimeout>750</commandtimeout> </timeout> <command> <command1 /> <command2 /> <command3 /> <command4 /> <command5 /> </command> <options> <loginmacro>False</loginmacro> <postcommands>False</postcommands> <endlinechar>10</endlinechar> </options> </connection> <connection type="PuTTY" name="AWSA"> <connection_info> <name>AWSA</name> <protocol>SSH</protocol> <host>303.233.542.622</host> <port>22</port> <session>Default Settings</session> <commandline>rrertd</commandline> <description /> </connection_info> <login> <login /> <password /> <prompt /> </login> <timeout> <connectiontimeout>1000</connectiontimeout> <logintimeout>750</logintimeout> <passwordtimeout>750</passwordtimeout> <commandtimeout>750</commandtimeout> </timeout> <command> <command1 /> <command2 /> <command3 /> <command4 /> <command5 /> </command> <options> <loginmacro>False</loginmacro> <postcommands>False</postcommands> <endlinechar>10</endlinechar> </options> </connection> </root> </configuration>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: how to update an xml file by read data from csv file
by bitingduck (Chaplain) on Nov 28, 2012 at 16:48 UTC | |
by Vijay81 (Acolyte) on Nov 29, 2012 at 21:38 UTC | |
by choroba (Cardinal) on Nov 29, 2012 at 21:48 UTC | |
by bitingduck (Chaplain) on Nov 30, 2012 at 10:00 UTC | |
by Vijay81 (Acolyte) on Dec 01, 2012 at 23:23 UTC | |
by bitingduck (Chaplain) on Dec 03, 2012 at 16:08 UTC | |
|
Back to
Seekers of Perl Wisdom