
Michael Grier - 2006-12-11 17:52:13
took some trial and error to figure this out, so here's the code I got to work for getting the content out of an nzb.
<?php
require_once("DOMAdapter.inc");
header("Content-Type: text/plain");
$xml=new DOMAdapter();
$doc=$xml->createDocument();
$doc->load('test.nzb');
$filelist=$doc->getElementsByTagName('file');
$files=$filelist->nodes;
foreach($files as $file){
$subject=$file->get_attribute('subject');
$poster=$file->get_attribute('poster');
$date=$file->get_attribute('date');
$groups=$file->get_elements_by_tagname('group');
$segments=$file->get_elements_by_tagname('segment');
echo $subject."\n";
echo ' '.$poster."\n";
echo ' '.$date."\n";
foreach($groups as $group){
echo ' '.$group->get_content()."\n"; // group name
}
foreach($segments as $segment){
echo ' '.$segment->get_attribute('number')."\n";
echo ' '.$segment->get_attribute('bytes')."\n";
echo ' '.$segment->get_content()."\n"; // message-id
}
}
?>