我有一个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 <bloggs@nowhere.example>"
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下载和组装此文件?我将不胜感激任何示例代码。提前谢谢。
答案 0 :(得分: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;