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

Re: Converting XML to MARC without reading a file?

Thread Previous | Thread Next
From:
Dr. Saiful Amin
Date:
April 19, 2018 08:24
Subject:
Re: Converting XML to MARC without reading a file?
Message ID:
CALetcjPnxY3n4AiK-xysTRoxAHq2TwkWpMRuqLwU4zZVVgvxww@mail.gmail.com
On Thu, Apr 19, 2018 at 5:55 AM, Andy Kohler <akohler726@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

Thread Previous | 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