On Thu, Apr 19, 2018 at 5:55 AM, Andy Kohler <akohler...@gmail.com> wrote:
> 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? > The function new_from_xml() should work without filehandle I think. I'm pulling a bunch of MARCXML records from a database and the code looks like this: while ( my $row = $sth->fetchrow_hashref() ) { my $marcxml = $row->{'marcxml'}; my $record = MARC::Record->new_from_xml( $marcxml, 'UTF-8' ); ... } -- Saiful Amin