Hi Perl Monks, after going through the documentation about the module XML::LibXML::Document,XML::LibXML::Node, i have come up with the latest code,again the expected portion of xml elements from source is getting displaced by the variable $TargetContent but the same is not written to the target file $OutFileName. The Target file is created by the below mentioned way,I ending the write( using $writer->end() ) and closing the target file( using $OutXmlFile->close() ) before calling the function GetMappletList. I hope,this will give more idea about what i am trying to do

my $OutXmlFile = IO::File->new(">$OutFileName"); my $writer = XML::Writer->new(OUTPUT => $OutXmlFile,DATA_MODE=>1,DAT +A_INDENT=>5);
sub GetMappletList { my $Target_node; my ($TableNm,$ColumnNm,$DomainNm,$AlgoNm); my @MaskingAlgorithmList; my @MappletNode; my $MpltRefFile_Dir = shift; my $MappletXmlName; open GET_MAPPLET_LIST, "<","$Profiler_Dir/$MpltRefFile_Dir/Inve +ntory.rpt" or die "ERROR : Couldn't Open $Profiler_Dir/$MpltRefFile_D +ir/Inventory.rpt $!"; while (my $InvtoryCol = <GET_MAPPLET_LIST> ) { chomp $InvtoryCol; ($TableNm,$ColumnNm,$DomainNm,$AlgoNm) = split(/ +,/,$InvtoryCol); if ($TableNm =~ /$SourceTableName/) { print " The Workflow xml nme is $OutFile +Name\n"; $MappletXmlName = "$Mapplet_Dir/$AlgoNm. +XML"; print "The Dir name is $MappletXmlName\n +"; my $MpltParser = XML::LibXML->new(); my $TargetXml = $MpltParser->parse_file( +"$OutFileName"); my $MpltXml = $MpltParser->parse_file("$ +MappletXmlName"); $SourceRoot= $MpltXml->documentElement() +; my @SourceNode = $MpltXml->findnodes("// +MAPPLET"); my $SourceRootNode = $SourceNode[0]; $TargetXml->setDocumentElement( '/POWE +RMART/REPOSITORY/FOLDER' ); #$TargetXml->setDocumentElement( '/POW +ERMART/REPOSITORY/FOLDER' ); $TargetXml->adoptNode($SourceRootNode) +; #$TargetXml->adoptNode('/POWERMART/REP +OSITORY/FOLDER/MAPPLET'); my $TargetContent = $TargetXml->addChi +ld($SourceRootNode); print $TargetContent; } } close(GET_MAPPLET_LIST); }

In reply to Copy portion of XML elements from one XML file to another exiting XML file by Dravidan

Title:
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, details, 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, summary, 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.