Open zhulingfang opened 6 years ago
If you could provide your inline trasformation JSON it would be easier to help you out.
But if your web.config is for exapmle:
<configuration>
... <!-- skipped other definitions -->
<hosts>
<host hostname="http://localhost:2469"/>
<host hostname="http://localhost:6299/"/>
</hosts>
... <!-- skipped other definitions -->
</configuration>
To replace these two hosts with some other values you could use this Inline JSON transformation:
{
"configuration/hosts/host[0]/@hostname":"http://first.hostname.local/",
"configuration/hosts/host[1]/@hostname":"http://second.hostname.local/"
}
Which should transform your configuration to:
<configuration>
... <!-- skipped other definitions -->
<hosts>
<host hostname="http://first.hostname.local/"/>
<host hostname="http://second.hostname.local/"/>
</hosts>
... <!-- skipped other definitions -->
</configuration>
How would you add those two entries? I tried unsuccessfully with
{ "configuration/hosts/host[]
0/@hostname":"http://first.hostname.local/",
"configuration/hosts/host[]1/@hostname":"http://second.hostname.local/" }
Actually, I was wrong, that did work.
I am trying to use Inline JSON to modify web.config file. In this file, I have two host under hosts: hosts host hostname="http://localhost:2469" host hostname="http://localhost:6299/" I am not able to pick up those two hostname to edit using xpath. Got following errors:
[error]System.Management.Automation.MethodInvocationException: Exception calling "Transform" with "4" argument(s): "The '[' character, hexadecimal value 0x5B, cannot be included in a name." ---> System.Xml.XmlException: The '[' character, hexadecimal value 0x5B, cannot be included in a name.
Is there anyway to address these two attributes or is this a bug? Need help on this.
Thanks!