cvs: peardoc /en/package/fileformats file-marc.xml /en/package/fileformats/file-marc reading.xml

From: Date: Mon, 12 Feb 2007 22:10:53 +0000
Subject: cvs: peardoc /en/package/fileformats file-marc.xml /en/package/fileformats/file-marc reading.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-9432@lists.php.net to get a copy of this message
dbs Mon Feb 12 22:10:53 2007 UTC Added files: /peardoc/en/package/fileformats/file-marc reading.xml Modified files: /peardoc/en/package/fileformats file-marc.xml Log: Reading MARC data using File_MARC... some examples. http://cvs.php.net/viewvc.cgi/peardoc/en/package/fileformats/file-marc.xml?r1=1.1&r2=1.2&diff_format=u Index: peardoc/en/package/fileformats/file-marc.xml diff -u peardoc/en/package/fileformats/file-marc.xml:1.1 peardoc/en/package/fileformats/file-marc.xml:1.2 --- peardoc/en/package/fileformats/file-marc.xml:1.1 Thu Feb 8 01:18:08 2007 +++ peardoc/en/package/fileformats/file-marc.xml Mon Feb 12 22:10:53 2007 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <sect1 id="package.fileformats.file-marc"> <title>File_MARC</title> @@ -11,8 +11,8 @@ &package.fileformats.file-marc.intro; &package.fileformats.file-marc.creating; &package.fileformats.file-marc.modifying; - &package.fileformats.file-marc.reading; --> + &package.fileformats.file-marc.reading; </sect1> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/peardoc/en/package/fileformats/file-marc/reading.xml?view=markup&rev=1.1 Index: peardoc/en/package/fileformats/file-marc/reading.xml +++ peardoc/en/package/fileformats/file-marc/reading.xml <!-- $Revision: 1.1 $ --> <refentry id="package.fileformats.file-marc.reading"> <refnamediv> <refname>Introduction</refname> <refpurpose> Introduction to <classname>File_MARC</classname> </refpurpose> </refnamediv> <refsect1 id="package.fileformats.file-marc.reading.overview"> <title>Overview</title> <para> <classname>File_MARC</classname> allows you to read Machine Readable Cataloging (<acronym>MARC</acronym>) data in MARC 21 format. <classname>File_MARCXML</classname>, which is bundled with <classname>File_MARC</classname>, allows you to read MARCXML formatted data. Your input source can be a PHP stream (SOURCE_FILE) or a string (SOURCE_STRING); specify the respective constant in the constructor. </para> <example> <title>Reading MARC 21 data from a file</title> <programlisting role="php"><![CDATA[ require 'File/MARC.php'; // Retrieve a set of MARC records from a file $journals = new File_MARC('journals.mrc', SOURCE_FILE); // Iterate through the retrieved records while ($record = $journals->next()) { // Pretty print each record print $record; print "\n"; } ]]> </programlisting> </example> <example> <title>Reading MARCXML data from a string</title> <programlisting role="php"><![CDATA[ require 'File/MARCXML.php'; // Retrieve a set of MARCXML records from a string $journals = new File_MARCXML($xml_data, SOURCE_STRING); // Iterate through the retrieved records while ($record = $journals->next()) { // Pretty print each record print $record; print "\n"; } ]]> </programlisting> </example> <para> A <classname>File_MARC</classname> object consists of a leader and an iterable set of <classname>File_MARC_Record</classname> objects representing MARC records. Each of these, in turn, consists of an iterable set of <classname>File_MARC_DataField</classname> or <classname>File_MARC_ControlField</classname> objects representing MARC fields. A <classname>File_MARC_DataField</classname> consists of a set of iterable <classname>File_MARC_Subfield</classname> objects representing MARC subfields. </para> <para> All of this means that <classname>File_MARC</classname> makes it very easy to read in a set of MARC records and iterate through the contents to retrieve specific fields and subfields. <classname>File_MARC</classname> offers convenience methods for retrieving specific fields without forcing you to iterate through the fields. <methodname>getField</methodname> returns the first field that matches the field name, while <methodname>getFields</methodname> returns an array of all of the fields that match the specified field name. Both of these methods accept an optional boolean parameter that specifies whether your match string should be treated as a Perl Compatible Regular Expression. </para> <example> <title>Retrieving all 650 fields from a record</title> <programlisting role="php"><![CDATA[ require 'File/MARC.php'; // Retrieve a set of MARC records from a z39 result string $bibrecords = new File_MARC($z39_result, SOURCE_STRING); // Iterate through the retrieved records while ($record = $bibrecords->next()) { // Retrieve an array of all of the 650 fields $subjects = $record->getFields('650'); if ($subjects) { // Retrieve just the first 24_ field print $record->getField('24.', true); print "\n"; // Now print all of the retrieved subjects foreach ($subjects as $field) { print $field; print "\n"; } print "\n"; } } ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->

« previous php.pear.doc (#9432) next »