Posted by johsw@drupal.org on February 5, 2007 at 4:05pm
Hi.
Do any of you guys have a module or parts of a module or just some codebits to do NITF to node parsing and insertion? I that case, I would really like to have a look. I'm considering doing my own from scratch, but a little snippet to get me going would be really cool.
Best,
/J.

Comments
hold on a week or so
Will have something soon which parses a series of NewsML URLs and stuffs them into CCK created special article nodes (with meta data, etc.)! You should be able to modify that for NITF.
If you are in a bigger hurry than that, contact me via the Contact Form, and I will let you know what I am doing and we can work together.
Victor Kane
http://awebfactory.com.ar
Victor Kane
http://awebfactory.com
interesting
would you mind sharing any progress here?
bert boerland
--
bert boerland
No progress...
So far I've tried parsing our nift-files. Unfortunately our NITF-use is really not stanard-compliant, so I have to do some "ugly" hacking. Now I'm gonna try using node_save to insert the parsed xml.
Best,
/Johs.
to bert and joshw, see above for some code snippets
Just a start, will clean up and drupalize shortly...
Victor Kane
http://awebfactory.com.ar
Victor Kane
http://awebfactory.com
OK, bits it is!
Well, got some pieces on the floor for the first iteration of an NITF oriented import script (it all works, but nothing useful yet, I hope soon).
Tasks for first iteration:
(it is meant to be executed like update.php, based on some of Moshe's devel module scripts)(Sorry about the Spanish).
What I have done up till now (see below for code):
a. With the Pear XML_NITF package at http://pear.php.net/package/XML_NITF as suggested by Yelvington
b. With SimpleXML functions at http://www.php.net/simplexml
Really cool is using the xpath capabilities!
c. With PHP 4 I had used the Pear unserializer, quick example at http://www.sitepoint.com/article/xml-php-pear-xml_serializer/3 , altho I do have some working examples of this, if anyone wants them. As suggested by Yelvington for PHP 4 http://pear.php.net/package/XML_Serializer/
That's it. In the next few days I will have tasks 3 and 4, and will post.
Here is the code (based on the example in the code, but I wanted to actually get it working):
a. With the Pear XML_NITF package on the nitf-fishing.xml file (adjust ini_set params for your setup)(stand-alone php):
<?php
ini_set("include_path", '/usr/share/php/' . PATH_SEPARATOR . ini_get("include_path"));
require_once 'XML/NITF.php';
$nitf = new XML_NITF();
$nitf->setInputFile('nitf-fishing.xml');
$xResult = $nitf->parse();
echo $nitf->getHeadline();
echo $nitf->getByline();
?>
b. With SimpleXML (stand alone php which generates stand alone html page):
Musings on how to pretend procedural php code can do what xsl does:
// whatever is recursive can be iterative with a case structure
// so the algorithm is to get the children; then for each child
// call a function that either does something specific (concatenates to output)
// or gets its children and calls the same function recursively
The hard part is going to be making this universal. The best hope will be to "extend" NITF to NewsML for what I will be needing, but that will come with refactoring later on.
Anyway, will be posting something cleaner shortly. Something based on a CCK generated fieldset, so when you hit enter it takes a URL you put in and takes and parses that. But that's just for show, since most work will be batch oriented, like the above import script.
Victor Kane
http://awebfactory.com.ar
Victor Kane
http://awebfactory.com
NITF progress
I'm looking at an NITF => Drupal project so any code people can share would be much appreciated.
FeedAPI parser for
FeedAPI parser for nitf?
http://groups.drupal.org/node/2667
http://www.twitter.com/lxbarth