my $marcxml = XML::LibXML->new->parse_string($xml);
$marcxml->documentElement->setNamespace($MARC_NAMESPACE, "marc", 1 );
$marcxml->documentElement->setNamespace($MARC_NAMESPACE);
+ # remove empty control fields - at least one source of records adds ersatz blank 008s
+ # that become empty controlfield elements
+ foreach my $controlfield ($marcxml->documentElement->getElementsByTagNameNS($MARC_NAMESPACE, 'controlfield')) {
+ $controlfield->parentNode->removeChild($controlfield) unless $controlfield->hasChildNodes();
+ }
return $marcxml;
}