File_MARC | File_Passwd |
File_MARC | |
PEAR Manual | |
The File_MARC_Record class enables you to write Machine Readable Cataloging (MARC) data in MARC 21 format, in a human-readable string format, and (with some restrictions) in MARCXML format.
To return a record in MARC 21 format, call the toRaw() method on the File_MARC_Record object.
Writing MARC 21 data to a file
In the following example, we have created one or more MARC records represented by File_MARC_Record objects stored in the $records array. To write this data to a file in MARC 21 format, we simply open the file in binary mode and write the contents of the records in the array to the file by calling the toRaw() method on each record in turn.
|
To return a human-readable version of a MARC 21 or MARCXML record, call the __toString() method on the File_MARC_Record object. Note that you call the __toString() method implicitly when you call the print() function on a File_MARC_Record object.
Returning a human-readable representation of MARC
In the following example, we print the contents of each MARC record in a human-readable format and also explicitly call the __toString() method so that we can write the human-readable contents to a file. Notice that it does not matter whether the source format is MARC or MARCXML, the methods we call to format the data for output are the same.
|
To return a record in MARCXML format, call the toXML() method on the File_MARC_Record object.
Significant restrictions on the toXML() method |
Writing MARCXML data to a file
In the following example, we have created a MARC record represented by a File_MARC_Record object stored in the $record variable. To write this data to a file in MARCXML format, we simply open the file in binary mode and write the record to the file by calling the toXML() method on the record object.
|
File_MARC | File_Passwd |
File_MARC | |
PEAR Manual | |