Jon Michael
04-05-2006, 06:56 AM
I'm writing a program file that reads an xml file and compares the settings in that .xml file to other servers that have the same .xml file - it's basically comparing the settings and writing to a log file as to whether it matches or doesn't match.
The problem I'm running into is toward the end of the .xml file, the lines in the .xml file are no longer unique - it uses the same naming convention for multiple setting instances.
For example.
<SpamIp4rLookups>
<name>blah</name>
<domainLookup>blahblah</domainLookup>
<description />
<weight>a number</weight>
<enabled>False</enabled>
<smtpenabled>False</smtpenabled>
</SpamIp4rLookups>
Another example.
<spamLevelLowAction>
<type>PrefixSubject</type>
<argument>blah-low: </argument>
</spamLevelLowAction>
Up to this point I've just doing matches on things like <type>(.*)<\/type> but I can no longer do that as it's only going to find the first match every time, and I want it to find all instances of that setting, but I want to keep it organized for each setting block.
I hope this makes sense - I'm just learning perl so this part has got me a bit stumped, I assume I would have to use hash references to accomplish this but am not sure.
Can anyone provide some insight?
Thanks.
The problem I'm running into is toward the end of the .xml file, the lines in the .xml file are no longer unique - it uses the same naming convention for multiple setting instances.
For example.
<SpamIp4rLookups>
<name>blah</name>
<domainLookup>blahblah</domainLookup>
<description />
<weight>a number</weight>
<enabled>False</enabled>
<smtpenabled>False</smtpenabled>
</SpamIp4rLookups>
Another example.
<spamLevelLowAction>
<type>PrefixSubject</type>
<argument>blah-low: </argument>
</spamLevelLowAction>
Up to this point I've just doing matches on things like <type>(.*)<\/type> but I can no longer do that as it's only going to find the first match every time, and I want it to find all instances of that setting, but I want to keep it organized for each setting block.
I hope this makes sense - I'm just learning perl so this part has got me a bit stumped, I assume I would have to use hash references to accomplish this but am not sure.
Can anyone provide some insight?
Thanks.