XML::Simple is currently used in an application, but an enhancement to be introduced needs more than XML::Simple can offer, hence a different XML module is required.
Of interest is XML::Smart, but I am having a little difficulty in getting the results required.
I need to:
a. read an XML file into memory,
[successful]
b. check that the structure and content is valid,
[partially successful, I tried $xml->apply_dtd(), while the function was successful, DTD is far too limiting. Current plan is to validate structure and content using perl functions.]
c. modify some of the content if required,
[not tried yet]
d. query the data and return content as required.
[Can anyone assist here?]
A simplified example of the xml file is below.
How should one search for specific data?
Example: How does one GET "data_source_type" where template_id="interface_rate", query type="script" and metric="inBitsSec".
To do this I suspect one needs to use indexes/key, but in order to achieve this, one needs to better understand: i(), is_node(), key(), nodes(), nodes_keys(), order() and path().
Is this a reasonable approach?
Is anyone able to provide more documentation on i(), key(), nodes(), etc?
Is anyone able to provide examples of the use of i(), key(), nodes(), etc?
<templates>
<template template_id="bandwidth_use">
<query type="snmp">
<metric data_source_type="COUNTER" convert="8">inOctets</metric>
<metric data_source_type="COUNTER" convert="8">otherOctets</metric>
</query>
<query type="snmp">
<metric data_source_type="COUNTER" convert="8">outOctets</metric>
</query>
<k_base>1000</k_base>
<vertical_label>bit/sec</vertical_label>
<short_label>bit/s</short_label>
</template>
<template template_id="interface_rate">
<query type="snmp">
<metric data_source_type="GAUGE" convert="1">inBitsSec</metric>
</query>
<query type="script">
<metric data_source_type="GAUGE">outBitsSec</metric>
<metric data_source_type="GAUGE">inBitsSec</metric>
</query>
<k_base>1000</k_base>
<vertical_label>bit/sec</vertical_label>
<short_label>bit/s</short_label>
</template>
</templates>
regards