in reply to Re^2: Lib::XML removing Node
in thread Lib::XML removing Node

Sure thing. ikegami's suggestion is probably the most portable way to handle it too. It skips some of the node nonsense (naked text between elements are nodes|children too) and it is the way I usually do it in code. This would remove any after the first of a given TAGNAME.

my @nodes = $doc->findnodes("//TAGNAME"); if ( @nodes > 1 ) { $_->getParentNode->removeChild($_) for @nodes[1..$#nodes]; }