Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

XML::Mini - Need Clone Element Functionality

by set_uk (Pilgrim)
on Dec 11, 2003 at 18:47 UTC ( [id://314111]=perlquestion: print w/replies, xml ) Need Help??

set_uk has asked for the wisdom of the Perl Monks concerning the following question:

This may very well be the wrong way to approach this but...
I have an XML Document which is a template for a job that will be run. Depending on the processing certain elements need to be taken, cloned and added back into the document with attributes altered.
I am using XML::Mini and thought I should be able to grab the element - copy it, alter it and add it back into the XML document.
However when I try this approch I end up with multiple elements all with the same value because the elements contain HashRefs - which obviously when modified all point to the same Hash.
I originally took the approach of generating the XML on the fly with subroutines which created the element. But doing it this way defeats my purpose of having the structure of the job defined within the XML. Plus it duplicates the information - being already defined in the XML and then programatically created in the code
. So I came to the conclusion that I needed to clone the element object - found the Clone module. And it works. :-)
Now I am thinking - is this the right way to approach this problem?
Anyone have any better suggestions about how to take a template XML document and transform it based on variables supplied at runtime? XSLT perhaps (i've been trying to avoid the learning curve for this)? Simon
  • Comment on XML::Mini - Need Clone Element Functionality

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://314111]
Approved by Aristotle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-18 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found