in reply to Appending Text of One XML Node to that of the Other
I wouldn't recommend this but just to show one way it could be done with XML::XPath.
poj#!/usr/bin/perl use strict; use XML::XPath; my $file = "test.xml"; my $xp = XML::XPath->new(filename => $file); my $xpath = '//MsgSig'; my $i=1; while ( $xp->exists($xpath."[$i]") ) { my $key = $xp->getNodeText($xpath."[$i]/Key"); my $desc = $xp->getNodeText($xpath."[$i]/Description"); $desc .= " ($key)"; #print "$desc\n"; $xp->setNodeText($xpath."[$i]/Description",$desc); ++$i; } print $xp->getNodeAsXML();
|
|---|