Re: XML_NITF
| From: | Brian Abent | Date: | Mon, 11 Apr 2005 15:55:34 +0000 |
| Subject: | Re: XML_NITF | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18688@lists.php.net to get a copy of this message | ||
mike@wormers.net wrote:
Hi, I'm a complete newbie to PHP, Pear and NITF. Im having trouble finding out how to use the NITF in the PEAR Repository. I've downloaded and installed ok, Im just trying to find out usage examples. Can someone please help and post out or email me? Thanks in advance, michael lewisHere is an example i've adapted from a site I've done. It displays an article and the first image. <?php $file = '/path/to/xml_nitf_file'; require_once 'XML/NITF.php'; $nitf =& new XML_NITF; $res = $nitf->setInputFile($file); if (PEAR::isError($res)) die('error'); $res = $nitf->parse(); if (PEAR::isError($res)) die('error'); $image = ''; if (($media = $nitf->getMedia()) && is_array($media)) {
foreach ($media as $m) {
if ('image' == $m['type']) {
$url = parse_url($m['source']);
$media_id = substr($url['path'],1);
$image = "<img class='newsPhoto' src='/path/to/{$media_id}' alt='News Image' />";
break; // only do the first image
}
}
}
// show image
echo $image;
// show headline
echo $nitf->getHeadline();
// show byline
echo $nitf->getByline();
// show body of the article
echo $nitf->getContent());
// show copyright
echo $nitf->getDocData('copyright');
?>