|Just another Perl shrine|
Outputting a hash as XMLby smeenz (Sexton)
|on Mar 15, 2005 at 02:41 UTC||Need Help??|
smeenz has asked for the
wisdom of the Perl Monks concerning the following question:
Greetings, O wise ones.
I'm writing an application to work with a Cisco Call Manager.. it provides an SOAP (XML over HTTP) interface, which it calls AXL.
Basically, I send it a properly formatted request, and it sends me a properly formatted reply, which may contain an error code, or the result I'm after.
For getXXXX requests, I'm just creating the request manually, because it's static and only one line long, and I'm using XML::Twig to parse the reply, and that all seems good.
The problem comes when I want to send a dynamic and larger request packet, to create a new phone on the call manager. In this case, the data exists in a hash, in the right structure, but I'm dammed if I can figure out how to get Twig to take an existing hash, and produce XML output.
I've tried doing it with XML::Simple, but that creates output that, which technically okay, is not formatted in a way that the AXL service likes:
With XML::Simple, I can produce this sort of thing:
But what I need is this:
I know that Twig can print() it okay, but the only way I can figure to get data into Twig in the first place is to parse an existing XML document, and if I could produce that, well then I wouldn't have a problem. My fallback position is to write my own routine to process a hash, similar to what the Data Dumper does.