0

我有一个 NZB 文件,如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<nzb xmlns="http://www.newzbin.com/DTD/2003/nzb">
 <head>
   <meta type="title">Your File!</meta>
   <meta type="tag">Example</meta>
 </head>
 <file poster="Joe Bloggs &lt;bloggs@nowhere.example&gt;" 
       date="1071674882" 
       subject="Here's your file! abc-mr2a.r01 (1/2)">
   <groups>
     <group>alt.binaries.newzbin</group>
     <group>alt.binaries.mojo</group>
   </groups>
   <segments>
     <segment bytes="102394" number="1">123456789abcdef@news.newzbin.com</segment>
     <segment bytes="4501" number="2">987654321fedbca@news.newzbin.com</segment>
   </segments>
 </file>
</nzb>

有没有办法使用 Indy IdNNTP 下载和组装这个文件?我将不胜感激任何示例代码。提前致谢。

4

1 回答 1

0

实际上,这很容易:

  Xml := TXmlVerySimple.Create;
  Xml.Text:=recieved_nzb;

  //Each <file> section
  ChildNodes := Xml.Root.ChildNodes;
  for q := 0 to ChildNodes.Count - 1 do
    begin    
      IdNNTP1.SelectGroup(ChildNodes.Items[q].Find('groups').Find('group').Text);
      SegmentNodes:=ChildNodes.Items[q].Find('segments').ChildNodes;

      //Each <segment> (message)
      for w := 0 to SegmentNodes.Count - 1 do
      begin
          idNNTP1.GetArticle(SegmentNodes.Items[w].Text,IdMessage1);
          IdMessage1.SaveToFile('c:\!!!!\'+SegmentNodes.Items[w].Text, false);
          Application.ProcessMessages;
      end;
    end;
于 2013-04-22T18:24:14.783 回答