I've been trying to figure out how to determine if a key (Voltage) exists in my xml file and finally settled on...
test.xml - <Settings ModelNumber="1" SerialNumber="13"> - <Channels> <Channel Name="FSC" Voltage="12" Threshold="15" /> <Channel Name="SSC" Voltage="10" Threshold="20" /> </Channels> - <Pods> </Pods> </Settings> use XML::Simple; $inst_set= XMLin($file); foreach my $Channel(@{$inst_set->{Channels}->{Channel}}){ if($Channel->{Voltage}){$settings_file=$file} #if the Voltage exis +ts, it must be the settings file } }
This works, i just KNOW this is not an elegant solution, and therefore probably not the most reliable, so looking for some feedback. Having made this work, now need to change the Voltage value in the original xml. Has anyone got recommendation on best module to use to modify the original file? Thanks Chris
In reply to confirming key in xml? by ccherri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |