Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Esteemed monks,

I have a simple sub in my module which looks like this:

sub _view_xml { my $self = shift; my $xml = XMLin( "ttscall1.xml" ); print Dumper $xml; my $xml = XMLout( $xml, Rootname => 'campaign' ); print $xml; return $xml; }
The file contains some XML which is in exactly the structure specified for the particular API I need to send it to:
<campaign menuid="10118-2" action="0" > <phonenumbers > <phonenumber number="4167781583" callid="1234abc" > <prompts> <prompt promptid="2" tts="Hello, this is a test." /> </prompts > </phonenumber> </phonenumbers> </campaign>
When I dumpt the hash I get this:
$VAR1 = { 'menuid' => '10118-2', 'action' => '0', 'phonenumbers' => { 'phonenumber' => { 'number' => '4167781583', 'prompts' => { 'prompt' => { 'tts' => 'Hello, this is a test.', 'promptid' => '2' } }, 'callid' => '1234abc' } } };
Which is kinda what I expected. But when I ask for the XML back again, It gets compressed or something, and produces:
<campaign action="0" menuid="10118-2"> <phonenumbers name="phonenumber" callid="1234abc" number="4167781583 +"> <prompts name="prompt" promptid="2" tts="Hello, this is a test." / +> </phonenumbers> </campaign>
How do I get XML::Simple to output the XML in the same form it was to begin with?

What happens when I submit the XML to the API? I get this response:

<?xml version="1.0"?><campaign errorid="16" comment="XML parse error: +PHONENUMBER tag missing or misplaced." />
. And I figure the same thing will happen for the <prompt> as well except it doesn;t get so far as parsing that yet.

Your assistance is appreciated! jdtoronto


In reply to XML::Simple is doing too much for me! Help please. by jdtoronto

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, 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, 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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (3)
    As of 2020-05-27 04:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      If programming languages were movie genres, Perl would be:















      Results (152 votes). Check out past polls.

      Notices?