Re: Converting XML to MARC without reading a file?
[email protected] ("Dr. Saiful Amin") Thu, 19 Apr 2018 13:53:45 +0530
| Newsgroups | perl.perl4lib |
|---|---|
| Message-ID | <CALetcjPnxY3n4AiK-xysTRoxAHq2TwkWpMRuqLwU4zZVVgvxww@mail.gmail.com> |
--0000000000007ad180056a2f4b22 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 19, 2018 at 5:55 AM, Andy Kohler <[email protected]> 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? > =E2=80=8BThe 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 =3D $sth->fetchrow_hashref() ) { my $marcxml =3D $row->{'marcxml'}; my $record =3D MARC::Record->new_from_xml( $marcxml, 'UTF-8' ); ... }=E2=80=8B -- Saiful Amin --0000000000007ad180056a2f4b22 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><br><div class=3D"gmail_extra"><div class=3D"gmail_quote">= On Thu, Apr 19, 2018 at 5:55 AM, Andy Kohler <span dir=3D"ltr"><<a href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>= ></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px= 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><di= v dir=3D"ltr"><div><div><div><div>Hi -<br><br></div>I'm pulling records= from the WorldCat Search API in MARCXML, and need to convert them to binar= y MARC for further evaluation, which I'll do via MARC::Record.<br><br><= /div>Problem: Converting from MARCXML via MARC::File::XML seems to require = reading the records from a file.=C2=A0 I've already got the XML stored = in a variable, retrieved via LWP::Simple->get().<br><br></div>Do I have = to write the XML to a file, then read it in again to convert it?=C2=A0 Or a= m I just missing something obvious?<br></div></div></blockquote><div>=C2=A0= <br><div style=3D"font-family: trebuchet\ ms, sans-serif;" class=3D"gmail_d= efault">=E2=80=8BThe function <span style=3D"font-family:monospace,monospac= e">new_from_xml()</span> should work without filehandle I think. I'm pu= lling a bunch of MARCXML records from a database and the code looks like th= is:<br><br><span style=3D"font-family:monospace,monospace">while ( my $row = =3D $sth->fetchrow_hashref() ) {<br>=C2=A0=C2=A0=C2=A0 my $marcxml =3D $= row->{'marcxml'};<br>=C2=A0=C2=A0=C2=A0 my $record =3D MARC::Rec= ord->new_from_xml( $marcxml, 'UTF-8' );<br>=C2=A0=C2=A0=C2=A0 ..= .<br>}=E2=80=8B</span></div></div></div><div style=3D"font-family: trebuche= t\ ms, sans-serif;" class=3D"gmail_default"> <div class=3D"gmail_default" style=3D"font-family: trebuchet\ ms, sans-seri= f;"></div><div class=3D"gmail_extra"><br clear=3D"all"><div><div class=3D"g= mail_signature"><div dir=3D"ltr">--<br>Saiful Amin<br></div></div></div> </div></div></div></div> --0000000000007ad180056a2f4b22--