Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-29 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found