I have an xml configuration file:
<?xml version="1.0"?>
<Tenant>
<Tenants>
<Tenant name="tenant_0" siteName="t100001" urlWebSite="qa.local" username="admin" password="admin" />
<Tenant name="tenant_1" siteName="t100002" urlWebSite="qa.local" username="admin" password="admin" />
<Tenant name="tenant_2" siteName="t100003" urlWebSite="qa.local" username="admin" password="admin" />
<Tenant name="tenant_3" siteName="t100004" urlWebSite="qa.local" username="admin" password="admin" />
</Tenants>
<Tenant>
Currently, I'm modifying each urlWebSite attribute with a new value $urlWebSite:
$urlWebSite = 'prod.local'
$siteName = @('t100001','t100002','t100003')
[xml]$config = Get-Content("path\xml.config")
Foreach($i in $config.Tenant.Tenants.childnodes){
$i.urlWebSite = "$UrlWebSite"
}
$config.save("path\xml.config")
I also need to remove a childnode from Tenants in case if childnode has siteName attribute witch is NOT in $siteName array.