use XML::LibXML; my $parser =XML::LibXML->new(); my $tree =$parser->parse_file($xml); my $root =$tree->getDocumentElement; my ($application_id_node) = $root->findnodes('//file/body/group/unit/alt-title/otherTitle/text()'); $application_id_node->removeChildNodes(); $application_id_node->appendText('new value');