@@ -22,34 +22,34 @@ composer require scriptotek/marc dev-master
22
22
23
23
## Reading records
24
24
25
- Records are loaded into a ` Collection ` object using
26
- ` Collection::fromFile ` or ` Collection::fromStringString ` ,
27
- which autodetects if the data is Binary MARC or XML:
25
+ Use ` Collection::fromFile ` or ` Collection::fromString ` to read one or more
26
+ MARC records from a file or string. The methods autodetect if the data is
27
+ Binary MARC or XML (namespaced or not).
28
28
29
29
``` php
30
30
use Scriptotek\Marc\Collection;
31
31
32
32
$collection = Collection::fromFile($someFileName);
33
33
foreach ($collection->records as $record) {
34
- echo $record->getField('250')->getSubfield('a') . "\n";
34
+ echo $record->getField('250')->getSubfield('a')->getData( ) . "\n";
35
35
}
36
36
```
37
37
38
- The package will extract MARC records from any container XML,
39
- so you can load an SRU or OAI-PMH response directly:
38
+ The package can extract MARC records from any container XML, so you can load
39
+ an SRU or OAI-PMH response directly:
40
40
41
41
``` php
42
- $response = file_get_contents('http://lx2.loc.gov:210/lcdb?' . http_build_query(array(
43
- 'operation' => 'searchRetrieve',
44
- 'recordSchema' => 'marcxml',
45
- 'version' => '1.1',
42
+ $response = file_get_contents('http://lx2.loc.gov:210/lcdb?' . http_build_query([
43
+ 'operation' => 'searchRetrieve',
44
+ 'recordSchema' => 'marcxml',
45
+ 'version' => '1.1',
46
46
'maximumRecords' => '10',
47
- 'query' => 'bath.isbn=0761532692',
48
- ) ));
47
+ 'query' => 'bath.isbn=0761532692',
48
+ ] ));
49
49
50
50
$collection = Collection::fromString($response);
51
51
foreach ($collection->records as $record) {
52
- echo $record->getField('245')->getSubfield('a') . "\n";
52
+ ...
53
53
}
54
54
55
55
```
0 commit comments