This repository has been archived on 2022-08-01. You can view files and clone it, but cannot push or open issues or pull requests.
Scraping-Alpha/patent_slurper.pl

30 lines
590 B
Perl
Raw Normal View History

2016-02-12 23:17:15 +00:00
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use XML::Parser;
use XML::SimpleObject;
2016-02-21 14:07:05 +00:00
my( $filename ) = @ARGV;
2016-02-12 23:17:15 +00:00
2016-02-21 14:07:05 +00:00
open IN, '<', $filename or die;
my @contents = <IN>;
close IN;
2016-02-12 23:17:15 +00:00
2016-02-21 14:07:05 +00:00
@contents = grep !/^\<\?xml/igm, @contents;
open OUT, '>', $filename or die;
print OUT @contents;
close OUT;
#
#my $file = 'ipg150106.xml';
#my $parser = XML::Parser->new(ErrorContext => 2, Style => "Tree");
#my $xso = XML::SimpleObject->new( $parser->parsefile($file) );
#foreach my $patent ($xso->child('us-patent-grant')) {
#print $patent->child('invention-title')->{VALUE};
# print "\n";
#}