Functions in the ElectricCommander Perl API return XML objects. For customers who want to use Perl to interface with ElectricCommander, but who do not have experience with XML, it would be useful to be able to convert these XML objects to native Perl data types. This article shows how the XML::Simple module can be used to convert XML objects into Perl data structures.
This solution is useful for applications in which you deal with large amounts of data (multi-megabytes) in one response, where the performance burden of XPath might be very costly. Also, you can use this solution any place the power of XPath's processing is not needed and the simplicity of dealing with native Perl variables is preferred.
- Execute a call to a function in the ElectricCommander Perl API
- Convert the result to an XML string
- Use the XML::Simple XmlIn() function to convert it to a perl data structure
- Use the Perl data structure to complete the desired task
Here is an overview of the solution's key elements, see the attached file for a full example that lists jobs and their completion outcome.