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

Hi,

understood your point! thanks but I am unable to implement it in my script. could you please provide me with a prototype or an example script for my problem ???

Can I see what you tried?

  • Comment on Re^3: how to remove an empty line from a xml file??

Replies are listed 'Best First'.
Re^4: how to remove an empty line from a xml file??
by ankit.tayal560 (Beadle) on Oct 01, 2016 at 09:29 UTC

    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;