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.csv
protocol,host,port and commandline
SSH,-P,22 103.243.543.233,erted
SSH,-P,22 303.233.542.622,rrertd
Xml file looks like :
Filename : std.xml
<!-- 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>
In the above xml file, protocol,host,port and commandline tag values are updated from csv file.
Output file which am looking for is :
<?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>