1. Go to this page and download the library: Download tacman/nitf-parser 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/ */
tacman / nitf-parser example snippets
use Tacman\NTF\NTF;
// Parse from file
$ntf = NTF::fromFile('article.xml');
// Or from XML string
$ntf = NTF::fromXml($xmlString);
// Or from a zip archive containing multiple NITF files
foreach (NTF::fromZip('articles.zip') as $ntf) {
echo $ntf->headline;
}
// Get a flat array ready for indexing
$searchable = $ntf->toSearchable();
$ntf = NTF::fromFile('article.xml');
$searchable = $ntf->toSearchable();
// Index directly into Meilisearch
$client->index('articles')->addDocuments([$searchable]);
// Iterate through all NITF files in a zip
$count = 0;
foreach (NTF::fromZip('archive.zip') as $ntf) {
$count++;
// Process each document
}
// Or get all as an array
$all = NTF::allFromZip('archive.zip');