Hello!
I've been trying to put a small script together to build out XML config files for a product at work. While you can edit the file by hand and file in all the blanks, its pretty big and error-prone. I figure if I just prompt the user for the items [or feed with a csv] it'd make life easier. I got most of it working.
Code is not too crazy. Load a template file and feed the variables into the elements. I'm doing the dot notation format which seemed easy enough. The one problem I have is elements that have multiple uh, sub-elements? I can address them to get it to spit out their value but if I try to set it, it wont set. No errors, just does nothing.
Example XML snippet:
I can call out like:
and that works fine
For say, DNSServers tho I can call out:
and it will echo the value from the file properly but if I put = "x.x.x.x" it just never sets it.
How do I address that scenario?
Thanks!
I've been trying to put a small script together to build out XML config files for a product at work. While you can edit the file by hand and file in all the blanks, its pretty big and error-prone. I figure if I just prompt the user for the items [or feed with a csv] it'd make life easier. I got most of it working.
Code is not too crazy. Load a template file and feed the variables into the elements. I'm doing the dot notation format which seemed easy enough. The one problem I have is elements that have multiple uh, sub-elements? I can address them to get it to spit out their value but if I try to set it, it wont set. No errors, just does nothing.
Example XML snippet:
XML:
<Gateway>x.x.x.x</Gateway>
<DNS>
<DNSServers>
<Server>x.x.x.x</Server>
<Server>x.x.x.x</Server>
</DNSServers>
<DNSDomain>someDomain</DNSDomain>
<SearchDomains>
<SearchDomainSuffix>someDomain</SearchDomainSuffix>
</SearchDomains>
</DNS>
I can call out like:
$xmldoc.DeploymentConfigurations.DeploymentConfiguration.HostManagement.Gateway = "x.x.x.x"
and that works fine
For say, DNSServers tho I can call out:
$xmldoc.DeploymentConfigurations.DeploymentConfiguration.HostManagement.DNS.DNSServers.Server[0]
and it will echo the value from the file properly but if I put = "x.x.x.x" it just never sets it.
How do I address that scenario?
Thanks!