nis123456_jsmith
xnis123456_jsmithx
1 Main Street
Maynard
MA
US
01754
8885551212
news.dev.sample@monster.com
- Job Body goes here
]]>
US
01754
NA
2011-11-28T00:00:00
2011-12-28T00:00:00
####
#!/usr/bin/perl -w
use strict;
use warnings;
use XML::Twig;
use Date::Manip;
use Data::Dumper;
my $datetoday = UnixDate("today","%m-%d-%Y");
chomp $datetoday;
my $xmlFile = "WacoTri_pre_$datetoday.xml";
my $xmlOut = "WacoTri_$datetoday.xml";
open (XMLOUT, ">$xmlOut");
my $twig = new XML::Twig( twig_handlers => { 'CompanyXCode' => \&lccXCode,
'JobPostingDates' => \&DoDate,
'nis:NISJob' => \&DumpOldAds
},
pretty_print => 'indented',
);
$twig->parsefile ($xmlFile);
$twig->flush;
$twig-> print (\*XMLOUT);
close XMLOUT;
sub DoDate
{ my ( $twig, $JobPostingDates)= @_;
my $dtidate = $JobPostingDates->first_child('JobActiveDate')->text;
my $dater = substr $dtidate, 0, 10;
my $newDate = (DateCalc($dater,"+ 7 days"));
my $outputdate = UnixDate($newDate, "%Y-%m-%d");
chomp $outputdate;
substr $dtidate, 0, 10, "$outputdate";
$JobPostingDates->first_child('JobExpireDate')->set_text($dtidate);
#$twig->flush;
}
sub lccXCode
{ my ( $twig, $CompanyXCode ) = @_;
my $XCode = $CompanyXCode->text;
my $lowercaseXCode = lc ($XCode);
$CompanyXCode->set_text ($lowercaseXCode);
}
sub DumpOldAds
{ my ($twig,$nisNISJob)=@_;
my $date = UnixDate("today", "%Y-%m-%d".'T00:00:00');
chomp $date;
my $adate = $nisNISJob->findvalue('.//JobActiveDate');
print "\n$adate -|- $date\n";
if( $adate ne $date) { $nisNISJob->delete; }
else { print $nisNISJob; };
}
####
nis123456_jsmith
xnis123456_jsmithx
1 Main Street
Maynard
MA
US
01754
8885551212
news.dev.sample@monster.com
- Job Body goes here
]]>
US
01754
NA
2011-11-28T00:00:00
2011-12-28T00:00:00
... Job with today's active date
... Job with today's active date