It is a typical error. It should be 172.27.166.170 in place of 172.27.166.178 i.e. replacing IP address from 172.27.166.170 to 172.27.166.178 , 172.27.166.171 to 172.27.166.179 and so on.
I think we have a language barrier here. When you say "It should be 172.27.166.170 in place of 172.27.166.178", we interpret that to mean that 172.27.166.178 should be changed to 172.27.166.170 and we are confused because the string 172.27.166.178 does not appear anywhere in your sample input.
Please show us the exact output you are trying to produce from your sample input (using CODE tags).
Answer RudiC's question about what should happen if the replacement values overflow a valid IP address segment.
And, explain whether the idea is just to increment values or whether the code is supposed to detect when the same IP address appears in the input and produce the same output for all occurrences of that that input IP address in the output.
I want
172.27.166.178 in place of 172.27.166.170, 172.27.166.179 in place of 172.27.166.171,
172.27.166.226 in place of 172.27.166.202, 172.27.166.227 in place of 172.27.166.203 and so on.
It is now clear as mud. You read an IP address from the input and your write an IP address to the output. Sometimes you add 8 to the input address to get the desired output address; sometime you add 24. How are we supposed to know what value to add (or subtract) to (or from) which input values if you don't give us a clear description of how your code is supposed to determine what random number to add or subtract from the input address?
Yes. You have an xml file. In that xml file you want to change four specific IP addresses to four other specific IP addresses. There is no pattern to the changes to be made to those IP addresses.
If I want to store the ip address in a variable e.g. for the below line
<ParamString StringId="PortAddress" StringValue="172.27.166.170" />I want to store .166.170 in a variable and replace that variable with value 166.178 and replace StringValue to "172.27.166.178" from 172.27.166.170 in the same file and so on.How can I do this?