I need to change the value of one node/key if another node/key has a particular value. For instance if the Name node = L1 in a channel element, change the value of the voltage node in that same channel element. I have to set the voltage in each channel according to the name value. I don't really care what the original voltage value is and would prefer to ignore it.
<Settings> <Channels> <Channel Name="R1" Voltage="100" Test="1"/> <Channel Name="R2" Voltage="200" Test="0"/> ... <Channel Name="L1" Voltage="400" Test="0"/> <Channel Name="L360" Voltage="120" Test="1"/> </Channels> </Settings>
So I would expect the code to work something like this...
if($root->findnodes('/Settings/Channels/Channel/Name="L1"')){ #<-Chan +nel name = "L1" my ($L1value) = $root->findnodes('/Settings/Channels/Channel/Name="L1 +" @Voltage[.="400"]'); $L1value->setValue(300); }
but that doesnt work. I cant figure out how to change the voltage based on the value of Name.
Thanks Monks CIn reply to how to change node value based on other node value by ccherri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |