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

how to include xml contents in another xml file

by perlCrazy (Monk)
on Aug 22, 2012 at 16:04 UTC ( #989085=perlquestion: print w/replies, xml ) Need Help??
perlCrazy has asked for the wisdom of the Perl Monks concerning the following question:

I am using xml::simple module to create xml file. have another template which is xml file. how to bring all the contents of template xml file into new xml file which is getting created ?

##Creating object for xml file my $xmls = XML::Simple->new( RootName => 'POWERMART', KeepRoot => 1, ForceContent => 1, ForceArray => ['SOURCE'] + + ); my $contents = {}; $contents->{POWERMART}->{creattion_date} = '02/08/2012'; ##Generate the xml file my $xmlFile = "test.xml"; $xmls->XMLout( $contents, xmldecl => '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".' +<!DOCTYPE POWERMART SYSTEM "powrmart.dtd">', OutputFile => $xmlFile );

Replies are listed 'Best First'.
Re: how to include xml contents in another xml file
by zentara (Archbishop) on Aug 22, 2012 at 16:07 UTC
Re: how to include xml contents in another xml file
by ig (Vicar) on Aug 22, 2012 at 18:43 UTC

    You can read your template file with XML::Simple, then add elements to the resulting data structure and, finally, create a new xml file from the combined contents, again with XML::Simple.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://989085]
Approved by herveus
[chacham]: survival of the fittest?
LanX "If Croesus goes to war he will destroy a great empire."
[LanX]: s/Croesus/May/

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2017-03-29 09:59 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (344 votes). Check out past polls.