I was thinking the same thing because that's what we do in Koha, but I
think Andy is getting back more than 1 XML record per HTTP request so I
don't think that will work.

That said he could use a XML streaming parser and LWP with callbacks and
then pass each individual record to new_from_xml.



On Thu, 19 Apr 2018, 6:24 PM Dr. Saiful Amin <mail2sai...@gmail.com> wrote:

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

Reply via email to