i have done it this way, but i need some other way using a module, $outputfile=shift; open(MYINPUT, "$outputfile"); # open for input my(@lines1) = <MYINPUT>; # read file into list my $value=5; foreach $line_new (@lines1) # loop thru list { if ($line_new =~ /a/) { my ($value) = $line_new =~ /value="(.*?)"/; print $transaction."\n"; my ($note) = $line_new =~ /note="(.*?)"/; print $reel_id."\n";
if($value ne '' && $note ne '') { $xml_text .= '<a value"'.$value.'"note="'.$ note.'" tape_id="'.$value.'">'; } else { $xml_text .= $line_new; } } else{ $xml_text .= $line_new; } } close MYINPUT; $outputfile_new="test.xml"; open(MYOUTPUT,">$outputfile_new") or die $!; print MYOUTPUT $xml_text; close MYOUTPUT; use XML::DOM; my $file = "test.xml"; # Read and parse the document my $parser = new XML::DOM::Parser; my $doc = $parser->parsefile ($file) or die $!; #print $xml_text; On Mon, Jun 21, 2010 at 10:57 PM, Bob goolsby <bob.gool...@gmail.com> wrote: > Mornin' -- > > What have you tried so far? > > If you post your Perl code here, we may be (will be) better able to assist > you. > > > B > > On Mon, Jun 21, 2010 at 3:06 AM, Chaitanya Yanamadala > <dr.virus.in...@gmail.com> wrote: > > Hai > > I have a small query regarding to xml reading and writng.. > > > > i have an xml like this > > <a value="5" note=2 > > > <b><c>hello</c></b> > > </a> > > > > now i need to add a new attribute to node a. > > > > can any one help me how to do it.. > > > > Chaitanya > > > > > > -- > > Bob Goolsby > bob.gool...@gmail.com >