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:

<newPhone name='bob' value1='blah' value2='blah2'/>

But what I need is this:

<newPhone> <name>bob</name> <value1>blah</value1> <value2>blah2</value2> </newPhone>
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.

In reply to Outputting a hash as XML by smeenz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.