AMF::Parser -- perl module to parse AMF data files
use AMF::Parser;
if ( AMF::Parser::open_file( $file ) ) { while ( my $rec = AMF::Parser::get_next_record() ) { print "Record (", $rec ->type, "):\n"; print "Title:\t", $rec ->get_value( 'title' ); ... } }
or simply
amf_open_file $file; # or, for instance amf_parse_string $string; my $rec = amf_get_next_record;
and then
my $id = $rec ->id; my $ref = $rec ->ref; my $ty = $rec ->type; if ( $ty eq 'person' ) { my $name = $rec ->get_value( 'name' ); ... }
AMF Parser parses AMF data. AMF is Academic Metadata Format, an XML-based language for academics-related data. http://amf.openlib.org/
This version of the module implements AMF as described by http://amf.openlib.org/doc/asakusa.html ; the latest AMF spec shall be at http://amf.openlib.org/doc/amf.html
open_file( FILE )
Opens an AMF file FILE for parsing. Conseqent calls to get_next_record()
will give you the extracted data objects. It doesn't read the whole file at
once, it only starts parsing it. This means if the file turns out to be not
well-formed XML you will not know that. You may simply get less records from
it than it contains. If the file is very big, you can process it record by
record, no problem.
Returns true on success, false otherwise.
parse_string( STRING )
Parses the STRING as AMF data. Returns true if no fatal error happened while parsing. A fatal error is either XML well-formedness error or an internal parser error.
get_next_record()
Returns the next record object (AMF::Record) from the currently parsed file or string, if there is any. Returns false otherwise (for instance, if end of file reached).
get_next_noun()
Returns the next noun object (AMF::Noun or AMF::Record) from the currently parsed file or string, if there is any. Returns false otherwise (for instance, if end of file reached).
amf_...
somethingModule exports by default functions amf_open_file, amf_parse_string,
amf_get_next_record, amf_get_next_noun
, which are the aliases of open_file,
parse_string, get_next_record, get_next_noun
respectively.
So use AMF::Parser
and you are ready to rock. If you don't want this, do:
use AMF::Parser ();
the AMF::Record manpage module, the amfch manpage utility
Ivan Kurmanov, http://www.ahinea.com/en/ for ACIS project, http://acis.openlib.org/