I'm starting with Perl, I know that there are some similiar questions answered, but (due to my lack of experiences) none of them was helpful.
I have xml like this:
<workflowVertices>
<workflowVertex>
<alias />
<task>Task_L2</task>
<vertexId>128</vertexId>
</workflowVertex>
<workflowVertex>
<alias />
<task>preTask_L1</task>
<vertexId>129</vertexId>
</workflowVertex>
</workflowVertices>
I need to delete all workflowVertex nodes that has node task =~ m/_L1/
What I have now:
my $dom = XML::LibXML->load_xml(location => $filename);
foreach my $name ($dom->findnodes('workflowVertices/workflowVertex/task'))
{
#say $name->to_literal();
if ($name->to_literal() =~ m/_L1/) {
say "JobName: " . $name->to_literal() . " to be deleted\n";
my $node = $name->to_literal();
my $parent = $name-> parentNode();
say $parent-> removeChild("task[$node]")
}
}
But when I execute it it falls on error:
XML::LibXML::Node::removeChild() -- node is not a blessed SV reference at
xmltransform.pl line 28.
Line 28. in my code is
say $parent-> removeChild("task[$node]")
Would anybody help me?