Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
In my opinion, XML::Simple is not the tool to use for this kind of work, especially as the complexity of your XML documents increases

XML::Simple is a great tool for

  • reading XML into a perl data structure
  • writing a perl data structure out to XML where the actual layout doesnt matter, only the well-formedness

By that second point I mean, you aren't contrained by someone elses DTD or XSD - there layout is important e.g. the <name> element must come before the <address> element if the XSD says so, but because XML::Simple is outputting a hash with 'name' and 'address' keys, you cant control that (well, you can, but you have to tie the hash to a package that will sort the keys for you)

In my opinion, if your going to be writing elements/nodes to an XML document, and you dont want to perturb any other parts of the document, your better off using an XML module that supports XPath navigation to locate your insert point, and using its API to insert the required nodes.

This is more robust than tweaking XML::Simple's many options to keep the source and result documents the same.

Another option is XSLT, but that's a whole other technology to master...

...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann

In reply to Re: XML::Simple Oddities and/or Philosophy by leriksen
in thread XML::Simple Oddities and/or Philosophy by osunderdog

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
    [Eily]: Discipulus I'd do that by starting from the bottom node I think. That way it can inherit the paths from the two nodes above (and so on, recursively)
    [LanX]: oh I meant fixed amount
    [LanX]: every path must have l left and r right edges and l and r are fixed and l+r is the height
    [LanX]: simple recursive function which goes left and right till l or r are exhausted
    LanX #solved
    [oiskuu]: I must watch Police Academy again sometime.

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (7)
    As of 2018-03-19 11:24 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (239 votes). Check out past polls.