in reply to Re^3: how to remove an empty line from a xml file??
in thread how to remove an empty line from a xml file??

hey was doing a silly mistake. tried the above code . it works! thanks for the help

use strict; use warnings; use Data::Dumper; use XML::DOM; my $parser=new XML::DOM::Parser; my $doc=$parser->parsefile('C:\perl\perl_tests\xmlin2.xml') or die$!; my $root=$doc->getDocumentElement(); my @address=$root->getElementsByTagName("address"); foreach my $address(@address) { if($address->getAttribute("name") eq "Joey") { if(my $item=$address->getElementsByTagName("item")->item(0)) { if(my $data=$item->getElementsByTagName("data")->item(0)) { $item->removeChild($data); my @list=$item->getChildNodes; foreach my $list(@list) { if($list->getNodeType==TEXT_NODE) { $item->removeChild($list); } } } } } } $doc->setXMLDecl($doc->createXMLDecl('1.0','UTF-8')); $doc->printToFile("C:/perl/perl_tests/xmlin2.xml"); $doc->dispose;