in reply to Using XML modules to remove XML elements
Here is an XML::Twig that will be easy on your RAM (only one journal is in mem at any given time).
#!/usr/bin/perl -w use strict; use XML::Twig; # you will actually get the list from a file my %to_remove= map { $_ => 1 } ( "1742-7061"); XML::Twig->new( twig_roots => { journal => \&journal }, pretty_print => 'indented', ) ->parse( \*DATA) # replace by parsefile( "file.xml") ->flush; sub journal { my( $t, $journal)= @_; # this works if the ISSN is a child of journal, # otherwise it might be a little more tricky. if( $to_remove{$journal->field( 'ISSN')}) { $journal->delete } else { $t->flush; } # ouput and cleanup memory } __DATA__ <bulk> <journal> <full-title>Acta Biomaterialia</full-title> <alternate-title></alternate-title> <ISSN>1742-7061</ISSN> <E-ISSN></E-ISSN> <vol-year></vol-year> <iss-vol>1</iss-vol> <start-date>01-01-1974</start-date> <target> <siteID>1</siteID> <rank>200</rank> <activate></activate> </target> </journal> <journal> <full-title>Acta Biomaterialia</full-title> <alternate-title></alternate-title> <ISSN>1743-7061</ISSN> <E-ISSN></E-ISSN> <vol-year></vol-year> <iss-vol>1</iss-vol> <start-date>01-01-1974</start-date> <target> <siteID>1</siteID> <rank>200</rank> <activate></activate> </target> </journal> </bulk>
|
|---|