If you actually want to do this as part of a larger system where running xml_grep would be a lesser-desired choice, XML::Twig is actually not that hard to use, once you get around its huge documentation ;-). You can also read some better docs on its website. Anyway, once you've loaded your XML file in to memory, you can just find the twig you're interested in (see get_xpath), and then just tell the object to "cut()" itself out, and you're done. You just need to print out the resultant XML to wherever you want.
use XML::Twig; my $xml = XML::Twig->new(); $xml->parsefile('foo.xml'); foreach my $el ($xml->get_xpath('dummy_record')) { $el->cut(); } $xml->print(\*STDOUT);
In reply to Re: Parsing XML file and removing the element
by Tanktalus
in thread Parsing XML file and removing the element
by sananpah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |