Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
So have you looked at using plain old XML::Parser? Just because you find a module called "XML::Simple", this doesn't mean that the fundamental module it's based on (XML::Parser) has to be really complicated -- and in fact it really is not complicated.

Clear your mind of XML::Simple, forget whatever preconceptions have arisen about how you think your code should be written, then read the man page for XML::Parser and see if some different approach becomes clear. You might find that it will be easier to use, and an appropriate algorithm might become self-evident.

(Consider that the man page for XML::Parser is only about one third as long as the one for XML::Simple -- that suggests to me that the latter module may have been misnamed.)

Your goal is not clearly stated here... (Maybe there's a previous thread where you gave more detail?) What needs to be modified? In what sense should the output be in "exactly" the same format, given that changes of some sort need to be made? (I.e. what specific features of the input format need to be preserved?)

And are you sure you need to hold the whole xml stream in a Perl data structure? Are there complicated, hierarchical conditions that are needed to control the mods? Or can the changes be based on relatively localized criteria?

Whatever the task is, XML::Parser will probably be simpler than XML::Simple (which seems to have been tailored to certain types of tasks, and your task might not be among that set).

Other references cited in earlier replies are worth looking at as well -- but I think looking at the fundamental module first would be worthwhile.

update: Sorry, I think I may have misunderstood. You are actually looking for a way to take a bunch of new data (from some non-XML source, like a database or flat file) and push them out in the XML format shown in the example -- is that it? You want a template with placeholders where you can plug in fresh values.

Since you seem to have some repeating elements ("voice_recipient_list" contains one or more "voice_recipients", etc) it's likely that different inputs will have different quantities of these elements. You could try setting up a set of nested templates -- e.g. a template for "voice_recipient" that can be used any number of times to build the "voice_recipient_list", then a template for "voice_broadcast_info" that has a placeholder for the "voice_recipient_list", and so on. But on the whole, it would seem more like you are building up the output from pieces, rather than just tweaking the content of an existing XML stream.

In reply to Re: Operating on XML, or XML::Simple is too simple! by graff
in thread Operating on XML, or XML::Simple is too simple! by jdtoronto

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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (10)
    As of 2020-11-25 17:34 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found