Converting XML to MARC without reading a file?

[email protected] (Andy Kohler) Wed, 18 Apr 2018 16:25:05 -0800
Newsgroups perl.perl4lib
Message-ID <CAGZXaBOKmBy=Yc3Y9zbmpFUyGPg3ogGpcXW7ocoRR+5fzGg+hw@mail.gmail.com>
--94eb2c0933e478a339056a289a78
Content-Type: text/plain; charset="UTF-8"

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

--94eb2c0933e478a339056a289a78
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div>Hi -<br><br></div>I&#39;m pulling reco=
rds from the WorldCat Search API in MARCXML, and need to convert them to bi=
nary MARC for further evaluation, which I&#39;ll do via MARC::Record.<br><b=
r></div>Problem: Converting from MARCXML via MARC::File::XML seems to requi=
re reading the records from a file.=C2=A0 I&#39;ve already got the XML stor=
ed in a variable, retrieved via LWP::Simple-&gt;get().<br><br></div>Do I ha=
ve to write the XML to a file, then read it in again to convert it?=C2=A0 O=
r am I just missing something obvious?<br><br></div><div>I&#39;ve tried thi=
ngs like:<br></div><div>$xml =3D get($api_call); # also verified that $xml =
now contains MARCXML for 1 or more records<br></div><div>my $batch =3D=C2=
=A0 MARC::File::XML-&gt;in($xml);<br>while (my $record =3D $batch-&gt;next(=
)) {<br>=C2=A0 print $record;<br>}<br></div><div>but I get the error: Can&#=
39;t call method &quot;next&quot; on an undefined value<br><br></div><div>T=
hanks --Andy<br><br></div></div>

--94eb2c0933e478a339056a289a78--