in reply to Re^2: Using XML modules to remove XML elements
in thread Using XML modules to remove XML elements
IN that case you can do something like:
Of course in your production code you will want to have all the ISSN numbers you want removed in a hash and do exists rather than the single comparison I have there.use XML::DOM; + + my $xml = 'jj.xml'; my $parser = new XML::DOM::Parser; my $doc = $parser->parsefile($xml); + my $nodes = $doc->getElementsByTagName ("ISSN"); + foreach my $node (@{$nodes}) { if ( $node->getFirstChild()->toString() eq '1742-7061' ) { my $parent = $node->getParentNode(); $doc->getFirstChild()->removeChild($parent); } + } + print $doc->toString();
/J\
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Using XML modules to remove XML elements
by eraymond (Novice) on Aug 05, 2004 at 15:44 UTC |