Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://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

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 musing on the Monastery: (3)
As of 2024-04-20 02:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found