MY CODE IS:
employ warnings and strictness;
use XML:: DOM; use Data:: Dumper;
my $parser = new DOM:: Parser XML;
my $root=$doc->getDocumentElement(); my $doc=$parser->parsefile('C:\perl\perl_tests\xmlin2.xml') or die$!
My $address(@address) = $root->getElementsByTagName("address"); foreach
"Joey") eq if($address->getAttribute("name"))
If (my $item=$address->getElementsByTagName("item")) then item(0)
If (my $data=$item->getElementsByTagName("data")) then {} item(0)
$doc->setXMLDecl($doc->createXMLDecl('1.0','UTF-8')); $item->removeChild($data); ~ } } } } } $doc->printToFile("C:/perl/perl_tests/xmlin2.xml"); $doc->dispose;
I parse xml files using XML:: DOM and make changes to them. I want to remove the empty line that appeared after I deleted the "data" element from my XML document, even though the data element was destroyed. How am I going to accomplish this? Any recommendations or fixes are appreciated.
employ warnings and strictness;
use XML:: DOM; use Data:: Dumper;
my $parser = new DOM:: Parser XML;
my $root=$doc->getDocumentElement(); my $doc=$parser->parsefile('C:\perl\perl_tests\xmlin2.xml') or die$!
My $address(@address) = $root->getElementsByTagName("address"); foreach
"Joey") eq if($address->getAttribute("name"))
If (my $item=$address->getElementsByTagName("item")) then item(0)
If (my $data=$item->getElementsByTagName("data")) then {} item(0)
$doc->setXMLDecl($doc->createXMLDecl('1.0','UTF-8')); $item->removeChild($data); ~ } } } } } $doc->printToFile("C:/perl/perl_tests/xmlin2.xml"); $doc->dispose;
I parse xml files using XML:: DOM and make changes to them. I want to remove the empty line that appeared after I deleted the "data" element from my XML document, even though the data element was destroyed. How am I going to accomplish this? Any recommendations or fixes are appreciated.