From below web.config file I want to copy the contents to another config file:
<?xml version="1.0"?>
<configSections>...</configSections>
<system.webserver>...</system.webserver>
<configuration>
<appSettings>
<add key="ConnectionString" value=" Data Source=192.168.1.19;Network Library=DBMSSOCN;Initial Catalog=Demo;Persist Security Info=True; User ID=sa;Password=powershell;Application Name=web;Connect Timeout=200; pooling='true'; Max Pool Size=200;"/>
<add key="ConnectionString1" value=" Data Source=192.168.1.19;Network Library=DBMSSOCN;Initial Catalog=Demo;Persist Security Info=True; User ID=sa;Password=powershell;Application Name=web;Connect Timeout=200; pooling='true'; Max Pool Size=200;"/>
<add key="ConnectionString2" value=" Data Source=192.168.1.19;Network Library=DBMSSOCN;Initial Catalog=Demo;Persist Security Info=True; User ID=sa;Password=powershell;Application Name=web;Connect Timeout=200; pooling='true'; Max Pool Size=200;"/>
<add key="key1" value ="value1"/>
<add key="key2" value ="value2"/>
<add key="key3" value ="value3"/>
<add key="key4" value ="value4"/>
.....<add key="key30" value ="value30"/>
</appSettings>
</configuration>
Tags which are copied from above config file need to show as below Expected config file "web1.config" with following contents:
From above xml file I want to copy only "ConnectionString,ConnectionString1,ConnectionString2" tags from <appSettings> parent tag as
<?xml version="1.0"?>
<appSettings>
<add key="ConnectionString" value=" Data Source=192.168.1.19;Network Library=DBMSSOCN;Initial Catalog=Demo;Persist Security Info=True; User ID=sa;Password=powershell;Application Name=web;Connect Timeout=200; pooling='true'; Max Pool Size=200;"/>
<add key="ConnectionString1" value=" Data Source=192.168.1.19;Network Library=DBMSSOCN;Initial Catalog=Demo;Persist Security Info=True; User ID=sa;Password=powershell;Application Name=web;Connect Timeout=200; pooling='true'; Max Pool Size=200;"/>
<add key="ConnectionString2" value=" Data Source=192.168.1.19;Network Library=DBMSSOCN;Initial Catalog=Demo;Persist Security Info=True; User ID=sa;Password=powershell;Application Name=web;Connect Timeout=200; pooling='true'; Max Pool Size=200;"/>
</appSettings>
<settings>
<add key="key1" value ="value1"/>
<add key="key2" value ="value2"/>
<add key="key3" value ="value3"/>
<add key="key4" value ="value4"/>
.....<add key="key30" value ="value30"/>
</settings>