小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

delphi讀寫(xiě)XML

 sumstars 2014-11-19
XML文件內(nèi)容;
  1. <?xml version="1.0" encoding="GB2312"?>
  2. <我的書(shū)>
  3.  
  4.    <漫畫(huà) 作者="小飛">
  5.         <書(shū)名>火影忍者</書(shū)名>
  6.         <價(jià)格>100</價(jià)格>
  7.     </漫畫(huà)>
  8.     <漫畫(huà) 作者="大飛">
  9.         <書(shū)名>死神</書(shū)名>
  10.         <價(jià)格>100</價(jià)格>
  11.     </漫畫(huà)>
  12.     <漫畫(huà) 作者="阿斗">
  13.         <書(shū)名>天牢</書(shū)名>
  14.         <價(jià)格>200</價(jià)格>
  15.     </漫畫(huà)>
  16.     <小說(shuō) 作者="阿斗">
  17.         <書(shū)名>天牢</書(shū)名>
  18.         <價(jià)格>200</價(jià)格>
  19.     </小說(shuō)>
  20. </我的書(shū)>



////////////
delphi內(nèi)容;
  1. unit Unit1;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls;
  6. type
  7. TForm1 = class(TForm)
  8.     Button1: TButton;
  9.     Memo1: TMemo;
  10.     XMLDocument1: TXMLDocument;
  11.     procedure Button1Click(Sender: TObject);
  12. private
  13.     { Private declarations }
  14. public
  15.     { Public declarations }
  16. end;
  17. mybook = class
  18.     name: string;
  19.     money: string;
  20.     author: string;
  21. end;
  22. var
  23. Form1: TForm1;
  24. implementation
  25. {$R *.dfm}
  26. procedure TForm1.Button1Click(Sender: TObject);
  27. var
  28. root: IXMLnode;
  29. lei: IXMLNode;
  30. info: IXMLNode;
  31. book: mybook;
  32. i: integer;
  33. begin
  34. xmldocument1.LoadFromFile('xml.xml');
  35. root := xmldocument1.DocumentElement;
  36. lei := root.ChildNodes.First;
  37. while lei <> nil do
  38. begin
  39.     if lei.NodeName = '漫畫(huà)' then
  40.     begin
  41.       book := mybook.Create;
  42.       book.author := lei.Attributes['作者'];
  43.       info := lei.ChildNodes.First;
  44.       while info <> nil do
  45.       begin
  46.         if info.NodeName = '書(shū)名' then
  47.           book.name := info.Text
  48.         else if info.NodeName = '價(jià)格' then
  49.           book.money := info.Text;
  50.         info := info.NextSibling;
  51.         //showmessage('中華人民共和國(guó)');
  52.       end;
  53.       memo1.Lines.Add(book.name + book.money + book.author);
  54.     end;
  55.     lei := lei.NextSibling;
  56. end;
  57. end;
  58. end.
寫(xiě)XML

  1. procedure TForm1.btn2Click(Sender: TObject);
  2. var
  3.     a, b, c:IXMLNode;
  4. begin
  5.     xmlDocument.Active := true;
  6.     xmlDocument.Version := '1.0';
  7.     xmlDocument.Encoding := 'gb2312';
  8.     a := xmlDocument.AddChild('第一個(gè)節(jié)點(diǎn)');
  9.     b := a.AddChild('第一個(gè)節(jié)點(diǎn)的子節(jié)點(diǎn)');
  10.     c := b.AddChild('第一個(gè)節(jié)點(diǎn)的子節(jié)點(diǎn)的子節(jié)點(diǎn)');
  11.     c.Text := '第一個(gè)節(jié)點(diǎn)的子節(jié)點(diǎn)的子節(jié)點(diǎn)的標(biāo)題';
  12.     xmlDocument.SaveToFile('e:\\pas\\Rule.xml');
  13. end;

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類(lèi)似文章 更多