use XML::LibXML 2; use XML::LibXML::PrettyPrint 'print_xml'; my $xml = XML::LibXML->load_xml(IO => \*DATA); # Promote elements out of their container $xml -> findnodes('//z/arit') -> foreach(sub { $_->parentNode->parentNode->appendChild($_) }); # Remove certain elements $xml -> findnodes('//z | //runhd | //i-g | //zp_pvg | //zp_cl | //ar | //zp_gr') -> foreach(sub { $_->parentNode->removeChild($_) }); print_xml $xml; __DATA__ abcabc /abc123/ abc is 123 (Reg) abc is a company.(Chinese translation): abc launched in 1992.Some other Chinese translation Symbolmarkrules, decision, the lawAnother SymbolSomething (positive) some symbol1+1=3