develooper Front page | perl.perl4lib | Postings from April 2018

Converting XML to MARC without reading a file?

Thread Next
From:
Andy Kohler
Date:
April 19, 2018 00:25
Subject:
Converting XML to MARC without reading a file?
Message ID:
CAGZXaBOKmBy=Yc3Y9zbmpFUyGPg3ogGpcXW7ocoRR+5fzGg+hw@mail.gmail.com
Hi -

I'm pulling records from the WorldCat Search API in MARCXML, and need to
convert them to binary MARC for further evaluation, which I'll do via
MARC::Record.

Problem: Converting from MARCXML via MARC::File::XML seems to require
reading the records from a file.  I've already got the XML stored in a
variable, retrieved via LWP::Simple->get().

Do I have to write the XML to a file, then read it in again to convert it?
Or am I just missing something obvious?

I've tried things like:
$xml = get($api_call); # also verified that $xml now contains MARCXML for 1
or more records
my $batch =  MARC::File::XML->in($xml);
while (my $record = $batch->next()) {
  print $record;
}
but I get the error: Can't call method "next" on an undefined value

Thanks --Andy

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About