⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_inputrss.pas

📁 realworld source code
💻 PAS
字号:
unit FM_InPutRss;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,xmldom, XMLIntf, msxmldom, XMLDoc,ComCtrls, ExtCtrls;

type
  TFMInPutRss = class(TForm)
    Button1: TButton;
    Button2: TButton;
    SaveDialog1: TSaveDialog;
    GroupBox1: TGroupBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    GroupBox2: TGroupBox;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    Bevel1: TBevel;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
    procedure ViewXML(XML_Node,XML_Node2:IXMLNode);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FMInPutRss: TFMInPutRss;

implementation
uses
 FM_RSS;
{$R *.dfm}

procedure TFMInPutRss.Button1Click(Sender: TObject);
var
 XMLDoc1,XMLDoc2:TXMLDocument;
 XMLNode,XMLNode1,XMLNode2:IXMLNode;
 //CreateRootNode,RootAttributes:IDOMNode;
 SList,Title,XMLUrl:TStringList;
 k:integer;
 ItemsParent:TTreeNode;
begin
 XMLDoc1:=TXMLDocument.Create(Self);
 XMLDoc1.FileName:=ExtractFilePath(Application.ExeName)+'RSSChannel.xml';
 XMLDoc1.Active:=True;
 XMLNode:=XMLDoc1.Node.ChildNodes.Nodes[0];
 XMLNode1:=XMLDoc1.Node.ChildNodes.Nodes[0];
 SList:=TStringList.Create;
 SList.Clear;
 Title:=TStringList.Create;
 Title.Clear;
 XMLUrl:=TStringList.Create;
 XMLUrl.Clear;
 if RadioButton1.Checked then
  if SaveDialog1.Execute then
   if SaveDialog1.FileName<>'' then
    begin
     XMLDoc1.SaveToFile(SaveDialog1.FileName+'.xml');
     Close;
    end;
 if RadioButton2.Checked then
   if (FMRSS.RzTreeView1.Selected<>nil)and(FMRSS.RzTreeView1.Selected.Parent<>nil) then
     if SaveDialog1.Execute then
      if SaveDialog1.FileName<>'' then
        begin
         ItemsParent:=FMRSS.RzTreeView1.Selected.Parent;
         k:=FMRSS.RzTreeView1.Selected.Index;
         while ItemsParent<>nil do
          begin
           SList.Add(inttostr(ItemsParent.index));
           ItemsParent:=ItemsParent.Parent;
          end;
         SList.Delete(SList.Count-1);
         while SList.Text <>'' do
          begin
           XMLNode:=XMLNode.ChildNodes.Nodes[strtoint(SList.Strings[SList.Count-1])];
           SList.Delete(SList.Count-1);
          end;
         XMLNode:=XMLNode.ChildNodes.Nodes[k];
         while XMLNode1.ChildNodes.Count<>0 do
         begin
           XMLNode1.ChildNodes.Delete(0);
         end;
         XMLNode1.ChildNodes.Add(XMLNode);
         XMLDoc1.SaveToFile(SaveDialog1.FileName+'.xml');
         Close;
        end;        
 if RadioButton3.Checked then
   if (FMRSS.RzTreeView1.Selected<>nil)and(FMRSS.RzTreeView1.Selected.Parent<>nil)then
    begin
     SaveDialog1.Filter:='*.opml|*.opml';
     if SaveDialog1.Execute then
       if SaveDialog1.FileName<>'' then
         begin
         ItemsParent:=FMRSS.RzTreeView1.Selected.Parent;
         k:=FMRSS.RzTreeView1.Selected.Index;
         while ItemsParent<>nil do
          begin
           SList.Add(inttostr(ItemsParent.index));
           ItemsParent:=ItemsParent.Parent;
          end;
         SList.Delete(SList.Count-1);
         while SList.Text <>'' do
          begin
           XMLNode:=XMLNode.ChildNodes.Nodes[strtoint(SList.Strings[SList.Count-1])];
           SList.Delete(SList.Count-1);
          end;
         XMLNode:=XMLNode.ChildNodes.Nodes[k];
         XMLDoc2:=TXMLDocument.Create(Self);
         XMLDoc2.Active:=True;
         XMLNode1:=XMLDoc2.AddChild('opml');
         XMLNode1.Attributes['Version']:='1.1';
         XMLNode1:=XMLNode1.AddChild('head');
         XMLNode1:=XMLNode1.AddChild('title');
         XMLNode1.NodeValue:='ReadWorld聚合资讯阅读器';
         XMLNode1:=XMLDoc2.ChildNodes.Nodes[0];
         XMLNode1:=XMLNode1.AddChild('body');
         {CreateRootNode:=XMLDoc2.DOMDocument.appendChild(XMLDoc2.DOMDocument.createElement('opml'));
         RootAttributes:=XMLDoc2.DOMDocument.createAttribute('version');
         RootAttributes.nodeValue:='1.1';
         CreateRootNode.attributes.setNamedItem(RootAttributes); }
         XMLNode2:=XMLDoc2.Node.ChildNodes.Nodes[0].ChildNodes.Nodes[1];
         if FMRSS.RzTreeView1.Selected.ImageIndex<>3 then
          ViewXML(XMLNode,XMLNode2)
         else
          begin
           XMLNode2:=XMLNode2.AddChild('outline');
           XMLNode2.Attributes['title']:=XMLNode.Attributes['Name'];
           XMLNode2.Attributes['text']:=XMLNode.Attributes['Name'];
           XMLNode2.Attributes['type']:='rss';
           XMLNode2.Attributes['xmlUrl']:=XMLNode.NodeValue;
          end; 
         XMLDoc2.SaveToFile(SaveDialog1.FileName+'.opml');
         XMLDoc2.Free;
         Close;
         end;
   end
   else
   Application.MessageBox('不可以从导出','错误',MB_OK OR MB_ICONWARNING);
 if RadioButton4.Checked then
  begin
    SaveDialog1.Filter:='*.opml|*.opml';
    if SaveDialog1.Execute then
       if SaveDialog1.FileName<>'' then
        begin
         XMLDoc2:=TXMLDocument.Create(Self);
         XMLDoc2.Active:=True;
         XMLNode1:=XMLDoc2.AddChild('opml');
         XMLNode1.Attributes['Version']:='1.1';
         XMLNode1:=XMLNode1.AddChild('head');
         XMLNode1:=XMLNode1.AddChild('title');
         XMLNode1.NodeValue:='ReadWorld聚合资讯阅读器';
         XMLNode1:=XMLDoc2.ChildNodes.Nodes[0];
         XMLNode1:=XMLNode1.AddChild('body');
         XMLNode2:=XMLDoc2.Node.ChildNodes.Nodes[0].ChildNodes.Nodes[1];
         ViewXML(XMLNode,XMLNode2) ;
         XMLDoc2.SaveToFile(SaveDialog1.FileName+'.opml');
         XMLDoc2.Free;
         Close;
        end;
  end;
 XMLDoc1.Free;
end;

procedure TFMInPutRss.ViewXML(XML_Node,XML_Node2:IXMLNode);
var
 i:integer;
 XMLNode:IXMLNode;
begin
 for i:=0 to XML_Node.ChildNodes.Count-1 do
  begin
   if XML_Node.ChildNodes.Nodes[i].NodeName='ChannelName' then
    begin
      XMLNode:=XML_Node2.AddChild('outline');
      XMLNode.Attributes['title']:=XML_Node.ChildNodes.Nodes[i].Attributes['Name'];
      ViewXML(XML_Node.ChildNodes.Nodes[i],XMLNode);
    end;
   if XML_Node.ChildNodes.Nodes[i].NodeName='Channel' then
    begin
     XMLNode:=XML_Node2.AddChild('outline');
     XMLNode.Attributes['title']:=XML_Node.ChildNodes.Nodes[i].Attributes['Name'];
     XMLNode.Attributes['text']:=XML_Node.ChildNodes.Nodes[i].Attributes['Name'];
     XMLNode.Attributes['type']:='rss';
     XMLNode.Attributes['xmlUrl']:=XML_Node.ChildNodes.Nodes[i].NodeValue;
    end;
  end;
end;
procedure TFMInPutRss.Button2Click(Sender: TObject);
begin
 Close;
end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -