PHP code example of sweetrdf / quick-rdf-io-raptor
1. Go to this page and download the library: Download sweetrdf/quick-rdf-io-raptor library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sweetrdf / quick-rdf-io-raptor example snippets
use \quickrdf\DataFactory;
use \quickRdfIo\Raptor\Parser;
// create a file handle for a n-quads/n-triple file
$fileHandle = fopen('/path/to/n-quads-file.nq', 'r');
// init a parser instance and read file handle
$parser = new Parser(new DataFactory());
$quadsIterator = $parser->parseStream($fileHandle);
// iterate through the quads
// note: the file isn't read before, only as you iterating $quadIterator
foreach ($quadsIterator as $quad ) {
var_dump($quad);
}
// free file handle
fclose($fileHandle);
use \quickrdf\DataFactory;
use \quickRdfIo\Raptor\Parser;
$str = '_:foo <http://foo> <http://bar> .';
// init a parser instance and read RDF string
$parser = new Parser(new DataFactory());
$quadsIterator = $parser->parse($str);
// iterate through the quads
foreach ($quadsIterator as $quad ) {
var_dump($quad);
}